Migrating from Next

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

The shape is one thing in Silgi: 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.

NextSilgiDifferences
"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 @silgi/reactreads the Form it is in
useOptimisticReact's useOptimistic, or useOptimistic from @silgi/reactSilgi'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 silgi/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 silgi/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