Skip to content

Private previewMost of the architecture is written. First public release in 2027.

Migrating from Next

These tables map the form and mutation features of Next to Hamur. They cover forms and handlers only; the tables on pages, data and the server in Migrating from Nuxt apply to any app. none means Hamur has no equivalent today.

The shape is one thing in Hamur: a handler, a typed function that runs on the server, exported from server/index.ts. A form posts to it (Form action={fn}), a component calls it (useAction(fn), useAsyncData(fn, input)), and with a route a URL answers it. It works without JavaScript, it is a public endpoint that must check who calls it, and it needs no directive.

NextHamurDifferences
"use server" at the top of a file or in a functiondefineHandler exports of server/index.tsthere is no directive; a handler is a module-level export, and a closure over component variables is not supported
<form action={serverAction}><Form action={fn}>works without JavaScript; a plain <form action={fn}> calls the stub with JavaScript only
useActionState(action, initial)useAction(fn, { initial })state, failure, error, pending in all six libraries
useFormStatus from react-domuseFormStatus from @hamur/adapter-reactreads the Form it is in
useOptimisticReact's useOptimistic, or useOptimistic from @hamur/adapter-reactHamur's takes the running handler calls
revalidatePath("/x")refresh(event, fn, input) in the handlerprimes the read the page makes next, so it sends nothing
revalidateTagnone
redirect("/x")redirect("/x") from hamur/appreturn or throw it
notFound()throw createError({ status: 404 })
cookies(), headers()getCookie(event, …), getRequestHeader(event, …)event is ctx.event
validate with Zod by handinput: schemaany Standard Schema; 400 Validation failed with data.issues
serverActions.bodySizeLimitserver.maxBodySizedefault 1 MiB; a handler's form.maxBodySize replaces it for that handler
serverActions.allowedOriginsserver.originCheck.allow
a Server Action as a public endpointthe sameauthorize inside every handler; see Every handler is a public endpoint
server-only packageserver-only or hamur/server-onlythe import guard fails the client build
route handlers (route.ts)a handler with a routeraw: true for a webhook or a raw body
after()none
streaming a result from an actionreturn an AsyncIterablethe caller iterates with for await

Rewrites, redirects and static params

next.config.js rewrites() and redirects() become routeRules; see Route rules. A has or missing list becomes when, and a rule with a condition is a list of entries.

ts
import { defineConfig } from "hamur";

export default defineConfig({
  framework: "react",
  routeRules: {
    "/docs/**": [{ when: { has: [{ type: "header", key: "x-beta" }] }, rewrite: "/guide/**" }],
    "/old/:slug": { redirect: { to: "/new/:slug", status: 308 } },
    "/promo": [{ when: { missing: [{ type: "cookie", key: "seen" }] }, redirect: { to: "/welcome", status: 307 } }],
  },
});
NextHamurDifferences
rewrites(): { source, destination }routeRules[source] = { rewrite: destination }the destination is an app path; an outside URL is a proxy rule. :slug stays :slug and :path* is ** (or **:path), filled in the target as ** or :path
redirects(): { source, destination }routeRules[source] = { redirect: destination } or { redirect: { to, status } }307 unless you give a status
permanent: truestatus: 308there is no permanent key; { to, permanent: true } fails at load with routeRules["/a"].redirect has no key "permanent"; write status: 308
has, missing with type: "header", "cookie", "query" or "host"when: { has, missing } on an entry of a listvalue is a regular expression matched as a whole; a named group is a param for the target. An entry under when takes redirect, rewrite, proxy, headers, noindex, swr, cache and ssr
a large list of redirectsredirects: "redirects.json"exact paths in a .json or .csv file, answered before the rules; see The redirects file
NextResponse.rewrite(url) in middleware.tsreturn rewrite(path) from a request stepa step of defineServer({ middleware }); see Server
generateStaticParams()export const entries in the page's x.load.tsit returns one object of params per path. A file that exports generateStaticParams fails the scan: app/pages/blog/[slug].load.ts exports generateStaticParams; Hamur reads entries (07 §4.1). See Data
export const dynamicParams = falseexport const dynamicParams = falsebeside entries, in the load file; a path that is not listed answers 404
Analog routeMeta: { redirectTo }a redirect rule in routeRules, or meta.redirect on the pagemeta.redirect becomes a rule under the page's path. With status: redirect: { to, status: 301 }