AbsoluteJS

Page Handlers

Specialized handler functions for server-side rendering with different frontend frameworks. All handlers provide complete type safety from server to client.

#Handler Behavior

Framework Handlers

React, Angular, Svelte, Vue handlers perform server-side rendering and return hydrated HTML.

Static Handlers

HTML and HTMX handlers serve pre-built files directly without SSR processing.

All handlers work seamlessly with Elysia's routing system and return properly formatted responses. Framework handlers require the manifest from prepare(). Always use asset(manifest, key) to look up script paths: it will throw if the artifact doesn't exist.

#handleReactPageRequest

Handles server-side rendering for React pages. The component is rendered to HTML with createElement, then hydrated on the client with the provided index script.

ParameterTypeDescription
pageComponentReact.ComponentType<Props>Your React page component from the pages directory
indexstringPath to the hydration script from asset(manifest, key)
propsPropsType-safe props matching the component requirements (optional)
optionsFrameworkPageHandlerOptionsEnable framework slot streaming by collecting registered slots during SSR. Disabled by default.
TS
import { asset } from '@absolutejs/absolute';
import { handleReactPageRequest } from '@absolutejs/absolute/react';
import { Elysia } from 'elysia';
import { Home } from './pages/Home';

const app = new Elysia()
  .get('/', () =>
    handleReactPageRequest({
      Page: Home,
      index: asset(manifest, 'HomeIndex'),
      props: { count: 0 }
    })
  )
  .listen(3000);

#handleAngularPageRequest

Handles server-side rendering for Angular pages. Uses a factory importer pattern for lazy loading Angular components.

ParameterTypeDescription
importer() => Promise<{ factory: AngularPageFactory<Props> }>Async function that imports the Angular page factory
pagePathstringPath to compiled Angular page for SSR
indexPathstringPath to hydration script from asset(manifest, key)
headTag`<head>...</head>`Custom head element (use generateHeadElement helper)
propsPropsType-safe props (optional if component has no props)
optionsFrameworkPageHandlerOptionsEnable framework slot streaming by collecting registered slots during SSR. Disabled by default.
TS
import { asset, generateHeadElement } from '@absolutejs/absolute';
import { handleAngularPageRequest } from '@absolutejs/absolute/angular';
import { Elysia } from 'elysia';
import type * as DashboardPage from './angular/Dashboard.server';

const app = new Elysia()
  .get('/angular', () =>
    handleAngularPageRequest<typeof DashboardPage>({
      pagePath: asset(manifest, 'Dashboard'),
      indexPath: asset(manifest, 'DashboardIndex'),
      headTag: generateHeadElement({
        title: 'AbsoluteJS + Angular',
        description: 'An Angular example with AbsoluteJS'
      }),
      props: { user: { name: 'Alex' } }
    })
  )
  .listen(3000);

#handleSveltePageRequest

Handles server-side rendering for Svelte pages. The component parameter is only used for type inference: the actual rendering uses the compiled page at pagePath.

ParameterTypeDescription
PageComponentSvelteComponent<Props>Raw Svelte component (used only for type inference)
pagePathstringPath to compiled Svelte page for SSR
indexPathstringPath to hydration script from asset(manifest, key)
propsPropsType-safe props (optional if component has no props)
optionsFrameworkPageHandlerOptionsEnable framework slot streaming by collecting registered slots during SSR. Disabled by default.
TS
import { asset } from '@absolutejs/absolute';
import { handleSveltePageRequest } from '@absolutejs/absolute/svelte';
import { Elysia } from 'elysia';
import type SvelteExample from './components/SvelteExample.svelte';

const app = new Elysia()
  .get('/svelte', () =>
    handleSveltePageRequest<typeof SvelteExample>({
      pagePath: asset(manifest, 'SvelteExample'),
      indexPath: asset(manifest, 'SvelteExampleIndex'),
      props: {
        initialCount: 0,
        cssPath: asset(manifest, 'SvelteExampleCSS')
      }
    })
  )
  .listen(3000);

#handleVuePageRequest

Handles server-side rendering for Vue pages. Vue components cannot include page elements like head, so you pass a headTag parameter (use generateHeadElement helper for convenience).

ParameterTypeDescription
_PageComponentVueComponent<Props>Raw Vue component (used only for type inference)
pagePathstringPath to compiled Vue page for SSR
indexPathstringPath to hydration script from asset(manifest, key)
headTag`<head>...</head>`Custom head element (use generateHeadElement helper)
propsPropsType-safe props (optional if component has no props)
optionsFrameworkPageHandlerOptionsEnable framework slot streaming by collecting registered slots during SSR. Disabled by default.
TS
import { asset, generateHeadElement } from '@absolutejs/absolute';
import { handleVuePageRequest } from '@absolutejs/absolute/vue';
import { Elysia } from 'elysia';
import type VueExample from './components/VueExample.vue';

const app = new Elysia()
  .get('/vue', () =>
    handleVuePageRequest<typeof VueExample>({
      pagePath: asset(manifest, 'VueExample'),
      indexPath: asset(manifest, 'VueExampleIndex'),
      headTag: generateHeadElement({
        cssPath: asset(manifest, 'VueExampleCSS'),
        title: 'AbsoluteJS + Vue',
        description: 'A Vue.js example with AbsoluteJS'
      }),
      props: { initialCount: 0 }
    })
  )
  .listen(3000);

#handleHTMLPageRequest

Serves static HTML files directly. The file still goes through the build process to update resource paths to their bundled versions.

ParameterTypeDescription
htmlstringPath to the HTML file
TS
import { handleHTMLPageRequest } from '@absolutejs/absolute';
import { Elysia } from 'elysia';

const app = new Elysia()
  .get('/html', () =>
    handleHTMLPageRequest('build/pages/HTMLExample.html')
  )
  .listen(3000);

#handleHTMXPageRequest

Serves HTMX template files. Like HTML handler, files go through the build process for path updates.

ParameterTypeDescription
htmxstringPath to the HTMX template file
TS
import { handleHTMXPageRequest } from '@absolutejs/absolute';
import { Elysia } from 'elysia';

const app = new Elysia()
  .get('/htmx', () =>
    handleHTMXPageRequest('build/pages/HTMXExample.html')
  )
  .listen(3000);