Getting started
Nifra is a contract-first TypeScript framework. Start with just a typed backend — like Hono or Elysia — and the client infers its types with zero codegen. Add a frontend only when you need one: the same route model then drives SSR across React, Solid, Vue, Preact, and Svelte, on Bun, Node, Deno, and the edge.
Install
bun add @nifrajs/coreA server — no frontend required
Chainable and fully type-inferred. This is a complete app: @nifrajs/core alone is a production backend (routing, validation, middleware, auth, WebSockets). Run it on Bun with .listen():
import { server } from "@nifrajs/core"
server()
.get("/", () => ({ hello: "world" }))
.get("/users/:id", (c) => ({ id: c.params.id }))
.listen(3000)An end-to-end-typed client
The server's types flow to the client — no schema duplication, no codegen — behind a never-throwing { data, error } result.
import { client } from "@nifrajs/client"
import type { app } from "./server"
// The client infers the server's types — no codegen. Never throws: { data, error }.
const api = client<typeof app>("http://localhost:3000")
const { data, error } = await api.users({ id: "7" }).get()
// ^? { id: string } | undefinedLoaders & the full stack
Route loaders call your backend in-process during SSR; actions handle mutations. Add streaming, defer(), optimistic UI, and a keyed query cache as you grow. The data model is framework-agnostic, so the renderer stays replaceable.
// A route's loader runs on the server (in-process during SSR, no network),
// fully typed against your contract.
export async function loader({ api }: LoaderArgs<typeof app>) {
const res = await api.users({ id: "7" }).get()
return { user: res.data }
}
export default function Page(props: { data: LoaderData<typeof loader> }) {
return <h1>{props.data.user?.id}</h1>
}Deploy anywhere
- Bun —
app.listen()(native). - Node / Deno — the
@nifrajs/node/@nifrajs/denoadapters. - Cloudflare Workers / Pages — edge build via
buildServer+toFetchHandler(the exact way this self-hosted site is compiled and served).
See the benchmarks for how it performs.