Docs

Migrate a frontend

Keep your UI framework and replace the meta-framework around it. Nifra has adapters for React, Preact, Solid, Vue, and Svelte; the routes, loaders, actions, and rendering features work the same across all five.

This guide covers React apps from Next.js or Remix / React Router, Preact SSR apps, SolidStart, Nuxt, and SvelteKit. Move one route at a time: copy the view, move its server data work into the matching .backend.ts file, and let the loader schema define what reaches the browser.

Scaffold the adapter you want with bun create nifra my-app --framework react (replace react with preact, solid, vue, or svelte). See Frameworks for adapter setup and file formats.

Map the route and data model

Starting pointNifra adapter and pageMove server data to
Next.js, Remix, React RouterReact, routes/example.tsxroute .backend.ts
Preact SSR / FreshPreact, routes/example.tsxroute .backend.ts
SolidStartSolid, routes/example.tsxroute .backend.ts
NuxtVue, routes/example.vueroute .backend.ts
SvelteKitSvelte, routes/example.svelteroute .backend.ts

A route is a view file plus its server half: for example routes/users/[id].tsx and routes/users/[id].backend.ts. Dynamic segments keep the [param] convention. Layouts move to _layout.tsx (or the matching adapter format); API handlers move to a server() backend and can be called in-process by loaders.

Move data loading and mutations once

Replace getServerSideProps, route loader functions, useAsyncData, and +page.server.ts with the same Nifra loader. It runs on the server, calls your API in-process during SSR, and returns only fields allowed byloaderOutput. Put mutations in action; native forms still work without JavaScript and client submissions revalidate the page data.

TS
// routes/users/[id].backend.ts - server-only data work, shared by every UI adapter
import { t } from "@nifrajs/schema"
import { notFound } from "@nifrajs/web"
import type { Route } from "./+types/[id]"

export const loaderOutput = t.object({ id: t.string(), name: t.string() })
export const loader: Route.Loader = async ({ params, api }) => {
  const result = await api.users({ id: params.id }).get()
  if (!result.ok) {
    if (result.status === 404) throw notFound()
    throw new Error("User API request failed (" + result.status + ")")
  }
  return result.data
}

React - Next.js, Remix, and React Router

Keep the React component. Move server fetching from a Next page, Server Component, or framework route loader into the paired backend file above. A route component receives typeddata as a prop. Nifra does not require React Server Components; if you need them, they are an opt-in feature on the shared route model; see Server components.

TSX
// routes/users/[id].tsx - React page, data is inferred from loaderOutput
import type { Route } from "./+types/[id]"

export default function User({ data }: Route.ComponentProps) {
  return <h1>{data.name}</h1>
}

Preact - Preact SSR and Fresh

Keep Preact JSX and component state. Replace Fresh or custom SSR route data with the shared backend loader, then author the page as a .tsx route using the Preact adapter. Fresh-specific middleware and route conventions move to Nifra's backend and file routes.

TSX
/** @jsxImportSource preact */
// routes/users/[id].tsx - Preact uses the same route and loader shape
import type { Route } from "./+types/[id]"

export default function User({ data }: Route.ComponentProps) {
  return <h1>{data.name}</h1>
}

Solid - SolidStart

Keep Solid components and signals. Move SolidStart route data into the shared loader; the page stays a .tsx file, with the loader result passed through props.

TSX
// routes/users/[id].tsx - keep Solid components and JSX
import type { Route } from "./+types/[id]"

export default function User(props: Route.ComponentProps) {
  return <h1>{props.data.name}</h1>
}

Vue - Nuxt

Move useAsyncData and server-only calls from Nuxt pages into the backend loader. Keep the template and author the Nifra route as a Vue Single-File Component. Its frontmatter exports live in the plain <script>; component props and markup live in <script setup> and <template>.

VUE
<!-- routes/users/[id].vue - the view stays a Vue Single-File Component -->
<script setup lang="ts">
const props = defineProps<{ data: { id: string; name: string } }>()
</script>

<template>
  <h1>{{ props.data.name }}</h1>
</template>

Svelte - SvelteKit

Move +page.server.ts data loading to the paired backend file. Keep the +page.svelte markup and component logic in a Nifra .svelte route; Svelte 5 receives route data through $props().

SVELTE
<!-- routes/users/[id].svelte - Svelte 5 props -->
<script lang="ts">
  let { data }: { data: { id: string; name: string } } = $props()
</script>

<h1>{data.name}</h1>

Map the rest of your frontend

Existing featureNifra equivalent
Nested layouts_layout.tsx or the adapter's layout format; parent data is shared with child routes
API route handlersA server() backend; loaders can use its typed client directly during SSR
Form actions and mutationsRoute action plus native form POST; client submissions revalidate loader data
Static generation and ISRprerender = true for SSG; withISR for revalidation
Metadata and document headNamed meta export, or a function of the loader data
Link prefetch and scroll restoreNifra's client router and Link, with hover/focus prefetch and scroll restoration
Image componentsImage from @nifrajs/web-<framework>/image
Tag or path revalidationAn action's revalidate(paths, data, { tags }) or revalidateEndpoint for a webhook
Partial prerenderingshellLoader and boundary loaders; see Partial prerendering
Intercepted modal routesA route boundary with an intercept target; see Modal routes
Keep-alive pageskeepAlive = true; see Keep-alive

What stays the same across adapters

  • Nested routes, layouts, metadata, forms, streaming, SSG, and ISR use the shared route model.
  • Route loaders and actions stay server-only; output schemas bound the data sent to the browser.
  • Switching among React, Preact, Solid, Vue, and Svelte changes the adapter and view syntax, not your backend contract.

Moving an API server too? See Migrate a backend. For the full rendering and route model, see Loaders & actions and Routing.

The current dynamic SSR snapshot reports Nifra at 15× the throughput of Next.js, 7× Nuxt, 3.9× SvelteKit, and 2.4× SolidStart on the measured pages. See the benchmark methodology and full results.