Troubleshooting
Common symptoms, their causes and their fixes. To look up an error, search this page for its wording.
On this page
this application wants mode: 'server'
Cause
Under static mode, the application uses something that needs a request. The first line of the error says what kind, and the lines below name the files.
Fix
If the application needs it, change the mode of framework() to 'server'. Remove site and csp, which only static mode accepts. Under server mode, write the CSP as a header in guard.ts, using nonce(). If only types are used, change the import to import type, which static mode lets through. If the application does not need it, remove that code. A GET form, such as a search or a filter, needs no Server Action.
static build needs the values of …
Cause
Under static mode, a parameter’s directory has no paths.ts. A build cannot choose the values itself.
Fix
For each parameter of the patterns the error names, put a paths.ts in its directory and return the values. If the page should answer values the build cannot know, give it a fallback.tsx.
framework() takes no … — under mode: … it takes …
Cause
The config passes framework() a key its mode does not take: often a misspelling, or an option that no longer exists, such as routesDir or paths. It stops even in a vite.config.js, which is never type-checked, rather than ignoring the key.
Fix
Pass only the keys the error lists. Route files live in src/routes/, and a parameter’s values come from the paths.ts in its directory.
… has to return an array of the values of …
Cause
The function in a paths.ts returned something other than an array of values with a URL spelling: often an empty string, an object, or a value that is not an array.
Fix
Return strings, numbers, bigints or booleans, and leave empty values out. Take the id or similar value out of an object before returning it. Return each value unescaped.
… is asked for its values once per value of the parameters above it, …
Cause
A parameter above the paths.ts has no paths.ts of its own. The build calls the function once per value above it, so without those values it cannot call it.
Fix
Give the directory of the parameter left in the path the error names a paths.ts too.
the paths.ts files stand where a params declaration refuses the values above them, …
Cause
A layout’s params above the paths.ts rejected a value a paths.ts above it returned, so the build did not call the one below for it. It happens as in /last/:slug, when the paths.ts beside a layout that reads the year as a number lists last.
Fix
Leave that value out of what the paths.ts above returns, or correct it.
paths.ts gives the values of its directory's parameter, …
Cause
A paths.ts sits in a directory that is not a parameter’s, such as [id]. The error is the same under either mode.
Fix
Move it into the directory of the parameter it returns values for.
these shells leave out a parameter a layout above their fallback.tsx receives, …
Cause
A layout above the fallback.tsx receives a parameter no paths.ts returns values for. The layout is written as HTML in the shell too, so it needs that value.
Fix
Give that parameter’s directory a paths.ts. When [locale]/paths.ts returns locales.all, a shell is written per locale, as at /ja/posts/:id.
a paths.ts returned !fallback, …
Cause
The build writes shells into directories named !fallback, so no paths.ts may return that value.
Fix
Rename the value, or leave it out of what the paths.ts returns.
the shell for … would also answer …
Cause
A shell’s rewrite rule would also match URLs of a route the route table tries first, and the host would answer those with the shell.
Fix
If that route is a page, give it a fallback.tsx too. If only one URL overlaps, return its value from a paths.ts so it is written as a page. Otherwise, give a parameter above a paths.ts, so the shell is written where that route cannot match.
the shells stand where a params declaration refuses the values above them
Cause
A layout’s params rejected a value a paths.ts above the shell returned, often a locale outside the set, as in /fr/posts/:id.
Fix
Leave that value out of what the paths.ts returns, or correct it.
the shell for … called notFound() while it rendered
Cause
A layout or a Server Component in fallback.tsx called notFound() while the build rendered the shell. A shell has no value, so there is nothing to look up yet.
Fix
Call notFound() from the Client Component that reads the value in the browser.
the shell for … was answered by …
Cause
Another route answered the shell’s URL (/posts/!fallback): a page that took !fallback as a value, or a page tried earlier in the route table with a fallback.tsx of its own and a differently named parameter in the same place.
Fix
For a page that took !fallback as a value, check that no paths.ts returns it. For another fallback.tsx, give a parameter above a paths.ts, so the shell is written where that route cannot match.
static build could not render …
Cause
Under static mode, a Server Component threw while the build rendered the page. When a Client Component with no Suspense boundary above it throws, the build stops with the same message.
Fix
The original error is logged above this message, beside the page’s URL. Start from there.
Pages that render only in vite dev
Cause
Under static mode too, vite dev writes no files and renders each page per request. When a Server Component throws, it responds with a 500 and keeps running. When a paths.ts throws, it logs the error once and renders every value with page.tsx.
Fix
Run vite build before you ship, and follow the message it stops with. Check the site it wrote with vite preview, which serves only the files in dist/client/, as a host does.
A page with a parameter is a 404 in vite dev
Cause
Under static mode, vite dev answers as the built site will. A value no paths.ts returned would have no page in the build, so it is a 404, and the log says k8ordo: no paths.ts returns /posts/3, so vite dev answers it with the not-found, …. Where a fallback.tsx sits beside the page, the shell answers instead.
Fix
Return the value from the paths.ts of the pattern the log names. If the data just gained the value, no restart is needed: the next request calls the paths.ts files again.
404.html served with a 200
Cause
Under static mode, the status that goes with 404.html is the host’s to decide. A build can write the page, but not the response.
Fix
Configure the host to serve 404.html with a 404 status for unknown URLs.
Values the build did not write are 404 on GitHub Pages
Cause
GitHub Pages has no rewrites and does not read _redirects, so a URL with no file gets 404.html.
Fix
Move to a host that rewrites, or return every value from a paths.ts.
Written pages answered with the shell on Cloudflare
Cause
Cloudflare reads at most 2,000 _redirects rules for fixed URLs. Past that it skips the rest, and the shell rules catch written pages too. The build warns with _redirects has … rules Cloudflare counts as static. Rules with parameters stop at 100, with the warning … counts as dynamic.
Fix
Write fewer values under patterns with a shell, and leave the rest to the shell. Netlify serves files first, so it never answers a written page with a shell.
Redirect loops on Cloudflare
Cause
Workers static assets run with assets.htmlHandling set to drop-trailing-slash. The shell rules rewrite to a URL ending in a slash, and the redirect that drops the slash sends the visitor round again. Under none, the shell is a 404.
Fix
Set assets.htmlHandling to the default auto-trailing-slash, or to force-trailing-slash.
_redirects cannot list …
Cause
A value the build wrote holds : followed by a letter, as in :b, or *. Hosts read those as placeholders, so no rule can answer that URL with its file, and on Cloudflare the shell answers it.
Fix
Use values whose URLs hold no : or *.
public/_redirects line … before its shell's rule
Cause
A rule in public/_redirects, such as /* /index.html 200, matches a shell location before the shell’s own rule does.
Fix
Remove that rule, or narrow it so it misses the shell locations.
vercel() takes beforeFiles and beforeNotFound under mode: 'static' only
Cause
A server mode application handed vercel() beforeFiles or beforeNotFound. Under server mode the handler answers every URL no file names, so there is nowhere for the routes to go.
Fix
Remove the options, and decide what is sent in a guard.ts or a route.ts.
… has "!fallback" in its HTML
Cause
Layouts receive the shell’s URL, /posts/!fallback, as pathname. Written into a link or a canonical URL, it leaves the HTML with something other than the visitor’s URL.
Fix
Render anything made from the URL in a Client Component that reads usePathname() in the browser.
the "csp" option cannot go into a page's <meta> as it is
Cause
Under static mode, the csp option holds something a <meta> cannot carry, such as a directive that works only from a header or 'strict-dynamic'. Those directives are frame-ancestors, report-uri, sandbox and report-to. An entry with several sources separated by spaces gets the same error.
Fix
Set the directives a <meta> ignores as headers at the host, and a policy that reports with report-to as a header there too. That header cannot carry the hashes the build adds page by page, so let its script-src allow 'self' and 'unsafe-inline', with no hash beside them. Drop 'strict-dynamic': the framework’s module script is allowed by 'self'. Give each source its own array entry.
Server Action submissions answered with a 403
Cause
Under server mode, the handler accepts a POST only when its Origin header names the host of the request’s URL. A proxy in front that rewrites Host makes the two disagree.
Fix
Have the proxy pass the original Host on unchanged. If you call the handler yourself, build the Request from the URL the visitor requested.
No redirect after redirect()
Cause
Under server mode, redirect() ends by throwing. Called inside a try, the catch receives that exception.
Fix
Call redirect() outside the try.
… belongs to what answers the request, and a page is a render
Cause
Under server mode, a page calls cookies(), responseHeaders() or requestHeaders() while it renders. These belong to the code that answers the request, not to a render.
Fix
To read the request’s headers or cookies, use the request the page receives. To write, move the code into a guard.ts or a Server Action.
A page that shows only internal error
Cause
Under server mode, the handler could not produce a response, and serve() responded with a 500. A Server Component that throws with no Suspense boundary above it leads here.
Fix
What was thrown is in the server’s log, on a line such as k8ordo: GET /products/1 failed. If the visitor should see a page of your own, add an error.tsx.
Cookies not kept over HTTP
Cause
Under server mode, secure defaults to true in cookies().set(). A browser does not keep a Secure cookie that arrived over HTTP without TLS. The default is false only for HTTP requests to localhost, 127.0.0.1 or [::1].
Fix
Serve production over HTTPS. Anywhere else you run over HTTP, pass secure: false to set.
a cookie with sameSite "none" has to be secure
Cause
Under server mode, a cookie with sameSite: 'none' was given secure: false. A browser drops SameSite=None without Secure, so cookies().set() throws on the spot.
Fix
Leave a sameSite: 'none' cookie secure, and serve over HTTPS.
CSS a page imports does not reach other pages
Cause
The CSS a page.tsx, not-found.tsx, route.ts or fallback.tsx imports, and the code that runs as it is imported, are not loaded until a page that renders that file is opened. A page relying on CSS another page imports gets it only once that page has been opened in the same tab. The CSS a Client Component imports is loaded as well when a link to that page is fetched ahead. Code that runs as it is imported takes effect on a server once that page has had its first request in that process, and under static mode the HTML written for a page may change with whether that page was prerendered before it.
Fix
Import the CSS and code every page needs in the root layout.tsx.
Styles that change with how a page is reached
Cause
CSS a page or a Client Component imports uses a selector that reaches past its own elements. CSS once loaded is never taken out, so once that page has been opened, or a link to it fetched ahead, the CSS applies to every page the tab moves to. The same goes for two Client Components’ CSS on one element, setting the same property with selectors of equal specificity. Which one applies goes by their order in <head>, and that order is not guaranteed.
Fix
Write the CSS a page or a Client Component imports with selectors that reach only its own elements, such as a CSS Module’s classes. Import CSS every page needs in the root layout.tsx. Where one Client Component’s CSS overrides another’s, give it a higher specificity, or declare the order of cascade layers at the top of the CSS the root layout.tsx imports.
… was preloaded using link preload but not used within a few seconds …
Cause
Chromium says this when a link was fetched ahead and its page was not visited. A prefetch also fetches that page’s Server Component CSS with <link rel="preload" as="style">, and that CSS applies only once the page is visited. Under static mode a touch screen fetches the links on screen ahead, so the warnings add up there.
Fix
The CSS fetched is used as it is once the page is visited, so the warning can be left alone. To have fewer of them, as for a long list, mark the link or an element around it data-k8ordo-prefetch="false".
Hydration errors only in production
Cause
The whole document the root layout renders is hydrated. When a CDN feature rewrites the HTML, it no longer matches what React renders. Web-font inlining, email obfuscation and script deferral are such features.
Fix
Turn that feature off. Serving fonts and scripts from your site’s own origin leaves the CDN nothing to rewrite.
no route table is registered with .k8ordo/ generated
Cause
The include in tsconfig.json does not cover .k8ordo/. The name starts with a dot, so an entry that names only the directory, ".k8ordo", does not pick it up. The types then look as they do right after a clone, and every pattern is a type error.
Fix
List it with a glob: .k8ordo/**/*.ts.
no route table is registered after a clone
Cause
.k8ordo/ is generated and not in git, so a fresh clone does not have it yet. Without the route table, every pattern handed to PageProps or href() is a type error saying no route table is registered. A name read from env says no server declaration is registered, and a message no locale set is registered.
Fix
Run k8ordo generate before tsc, so .k8ordo/ is generated. It builds nothing, so it goes before tsc in CI as well.
src/i18n.ts does not export …
Cause
In an application that depends on @k8ordo/i18n, src/i18n.ts does not export the locale set by the name locales. export * and a type-only export do not count. @k8ordo/i18n’s Register is then not generated, and every message is a type error saying no locale set is registered.
Fix
Export it from src/i18n.ts by name, as in export const locales = defineLocales(…). A set defined in another module can be re-exported with export { locales } from './lib/locales'.
Register not generated
Cause
The application’s package.json lists @k8ordo/i18n in neither dependencies nor devDependencies. Installed only as another package’s dependency, it does not count, and Register is not generated. Nor is it without a src/i18n.ts. Neither case warns.
Fix
Add @k8ordo/i18n to the application’s dependencies, and export the locale set from src/i18n.ts as locales.
routes/ holds only page.tsx, …
Cause
A file under routes/ is not a route file such as page.tsx or layout.tsx. That includes page.ts, with the wrong extension, and a file in a directory whose name starts with _, such as _parts/. When that directory has no page, the build also reports that it declares no route.
Fix
Move components to src/components/ and every other module to src/lib/, and update the imports. For a page, use the .tsx extension.
fallback.tsx placement errors
Cause
A fallback.tsx belongs beside a page.tsx that has a parameter. Anywhere else, the error lists a line routes/<path>: fallback.tsx …, under either mode.
Fix
With no page.tsx beside it, move the fallback.tsx to the page’s directory. Move a layout.tsx beside it one directory up, or fold it into page.tsx and fallback.tsx. Remove a fallback.tsx for a page with no parameter. When a layout above receives every parameter, remove the fallback.tsx too, and return the values from a paths.ts.
params: a route file exports … as params, which takes field.object({ … }) …
Cause
A route file exports, as params, a value field.object({ … }) did not build, such as a zod schema or an object written by hand. It throws as the pattern is read.
Fix
Rewrite the declaration with field from @k8ordo/field. A transform, or a check that the data exists, has no place in a declaration: make it in the page, and call notFound() when it fails.
'server-only' cannot be imported in client build
Cause
A module that imports server-only is reached from a Client Component. The lines below the first are the chain of imports that got it there.
Fix
Do not import it from the Client Component. Import it in a Server Component instead, and pass what it gives you down as props.
Functions cannot be passed directly to Client Components
Cause
A Server Component passes a function to a Client Component as a prop. Props are serialized on the way, and a function cannot be.
Fix
Pass the value the function returns, or move the function into the Client Component.
useParams: no matched <Router> above it
Cause
useParams() is imported from @k8ordo/router. Under this framework the browser holds no route table, so it has no route to read.
Fix
Pass the params the page received down to the Client Component as props. Inside the Client Component, useMatch() given the pattern reads them too.