Skip to content

Server-Side Rendering

renderToString

ts
import { renderToString, h } from 'nexa-framework'

const html = renderToString(h('div', null, ['Hello SSR']))
// → '<div>Hello SSR</div>'

Hydration

ts
import { hydrate, h } from 'nexa-framework'

// Hydrate server-rendered HTML
hydrate(h(App, null), document.getElementById('app')!)

Component Structure

For isomorphic rendering, components should avoid browser-only APIs in setup(). Use onMounted for client-only code:

ts
setup() {
  onMounted(() => {
    // browser-only code here
  })
  return { /* shared state */ }
}

Released under the MIT License.