Stone.jsDocs
Paradigm

Frontier

Universal apps

Server-side rendering is usually sold as a special build with its own rules. Under the Continuum it is something simpler and stranger: the same pages, resolved by two contexts, one after the other. Once you see it that way, hydration stops being magic.

#SSR is a superposition

The principle

A page rendered on the server and then made interactive in the browser was resolved twice: first by a server context for the initial HTML, then by a browser context for everything after. Same component, two measurements.

In Stone.js

You do not configure an "SSR mode". You stack a server adapter and the Browser adapter on one app. The server context collapses the first paint; the browser context collapses the rest. The pages never know which one is running them.

app/Application.tsdeclarativeimperative
import { StoneApp } from '@stone-js/core'
import { Routing } from '@stone-js/router'
import { UseReact } from '@stone-js/use-react'
import { Browser } from '@stone-js/browser-adapter'
import { NodeHttp } from '@stone-js/node-http-adapter'

@Browser()    // resolve in the browser (hydration, client nav)
@NodeHttp()   // ...and on the server (first paint)
@UseReact()
@Routing()
@StoneApp()
export class Application {}
import { defineStoneApp } from '@stone-js/core'
import { routerBlueprint } from '@stone-js/router'
import { useReactBlueprint } from '@stone-js/use-react'
import { browserAdapterBlueprint } from '@stone-js/browser-adapter'
import { nodeHttpAdapterBlueprint } from '@stone-js/node-http-adapter'

export const App = defineStoneApp(
  { name: 'tasks-ui' },
  [routerBlueprint, useReactBlueprint, browserAdapterBlueprint, nodeHttpAdapterBlueprint]
)

#Why this is more than a trick

Because both resolutions run the same domain, there is no separate server codebase to keep in sync with the client. A loader that fills a page on the server is the same loader that fills it on a client navigation. The seam between server and browser, the usual source of universal-app bugs, is gone by construction.

The first paint and the first interaction are the same page, collapsed by two contexts in a row.

Stone.js

Your app exists in every runtime. Until you run it.

An open-source project by Stone Foundation
Created by Mr. Stone (Evens Pierre)