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 point | Nifra adapter and page | Move server data to |
|---|---|---|
| Next.js, Remix, React Router | React, routes/example.tsx | route .backend.ts |
| Preact SSR / Fresh | Preact, routes/example.tsx | route .backend.ts |
| SolidStart | Solid, routes/example.tsx | route .backend.ts |
| Nuxt | Vue, routes/example.vue | route .backend.ts |
| SvelteKit | Svelte, routes/example.svelte | route .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.
// 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.
// 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.
/** @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.
// 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>.
<!-- 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().
<!-- 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 feature | Nifra equivalent |
|---|---|
| Nested layouts | _layout.tsx or the adapter's layout format; parent data is shared with child routes |
| API route handlers | A server() backend; loaders can use its typed client directly during SSR |
| Form actions and mutations | Route action plus native form POST; client submissions revalidate loader data |
| Static generation and ISR | prerender = true for SSG; withISR for revalidation |
| Metadata and document head | Named meta export, or a function of the loader data |
| Link prefetch and scroll restore | Nifra's client router and Link, with hover/focus prefetch and scroll restoration |
| Image components | Image from @nifrajs/web-<framework>/image |
| Tag or path revalidation | An action's revalidate(paths, data, { tags }) or revalidateEndpoint for a webhook |
| Partial prerendering | shellLoader and boundary loaders; see Partial prerendering |
| Intercepted modal routes | A route boundary with an intercept target; see Modal routes |
| Keep-alive pages | keepAlive = 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.