Pages and Layouts
How to write the React side of a route
page.tsx
import { page, type PageData } from './route.gen'
export default function OrderPage() {
const order = page.useLoaderData()
return <OrderItems />
}
export const head = ({ loaderData }: { loaderData?: PageData }) => ({
meta: loaderData ? [{ title: loaderData.id }] : [],
})
- UI only, no data loading.
./route.genis a generated module, one per folder, that exportspageandlayout(the TanStack routes of the page and the Layout, only when the folder has them),PageDataandLayoutData(the return types ofLoadandLayout),PageSearchandLayoutSearch(the query parameters they read, see Query parameters in Link and navigate),Params, and a function per method handler. Child components in the same folder also import./route.gen. A Layout's data comes from theroute.genof its folder:layout.tsximportslayoutfrom'./route.gen', and a page reads its project Layout withlayoutfrom'../../route.gen', for example. A folder with no generated module fails the build when something imports itsroute.gen. - The default export is the page component. Optional exports:
headandErrorBoundary. A 404 shows inErrorBoundarytoo (see 404), and exportingNotFoundfails the build. - In the browser, each
page.tsx, and eachlayout.tsxorlayout_.tsxbut the root Layout's, is a chunk of its own with everything it imports,headincluded. It loads the first time its route is needed, and the router waits for it before it shows the page or runshead. The HTML of a page preloads the chunks of its Layouts and route, so they arrive with the entry script. Code at the top level of the file, side-effect imports included, runs then and not when the app starts, so put setup that every page needs insetup.ts, which runs before any route module. See Route modules in the browser. - Go slices and maps are never
null: a nil slice arrives as[]and a nil map as{}, and their TypeScript types have no| null(see JSON rules). - Put components that need browser features at the module top level into a
.client.tsxfile, and load them lazily withclientOnlyfromtifa/client. They are left out of the SSR bundle, and the first paint shows a placeholder. Components that render but show nothing until the browser draws them belong there too, see Components that draw only in the browser:
import { clientOnly } from 'tifa/client'
const OrderActions = clientOnly(() => import('./actions.client'), <button disabled>Loading…</button>)
- Tifa never reloads page data for you. After a write, a handler function or a
fetchof your own, the page shows what it showed before until you ask: call TanStack'srouter.invalidate()to load the data of the current page and all its Layouts again, merged into one request.await router.invalidate({ sync: true })resolves once the page shows the new data. A plainawait router.invalidate()resolves at once and the page updates in the background. See Calling method handlers from the browser. - Data the router already holds follows TanStack's defaults. It counts as stale at once, so going back to a page you visited shows the cached data and loads it again in the background (
GET <url>?_tifa=…), and a link preloaded on hover or focus is reused for 30 seconds.
Query parameters in Link and navigate
The query parameters a Load or Layout function reads have types in the browser. route.gen exports them as PageSearch and LayoutSearch, and the route gets them, so TanStack's Link, navigate and useSearch check them:
func Load(c *tifa.Ctx) (Products, error) {
return products.List(c.Query("sort"), c.QueryValues("color"))
}
// in route.gen.ts
export type PageSearch = {
"color"?: string | string[]
"sort"?: string | string[]
[key: string]: string | string[] | undefined
}
<Link to="/products" search={{ sort: 'price', color: ['red', 'blue'] }}>…</Link>
<Link to="/products" search={{ sort: 2 }}>…</Link> // type error: the value is a string
navigate({ to: '/products', search: (prev) => ({ ...prev, sort: 'name' }) })
const search = page.useSearch() // PageSearch, with the parameters of the Layouts above
const sort = [search.sort].flat()[0] // the first value, as c.Query reads it
- A key can come more than once in a URL, so a value is a
stringor astring[]when you read it, whether Go reads it withc.Queryorc.QueryValues.c.Queryin Go takes the first value. Writing one, a single string is enough. Every key may be left out. - Other keys are open: a page may keep parameters of its own in the URL that Go does not read, such as the open tab of a panel. They are strings or arrays of strings too. So a misspelled key is not a type error, only a wrong type for a key Go reads is. The server render does not see them, see Query parameters in the server render.
- Only strings go in. The router writes every value as text, and Go reads text, so
'2', not2, and'1'or'true'as your Go code compares it. - The types come from the names Go reads, also through helpers and other packages, and each route has those of its own
LoadorLayout. TanStack adds those of the Layouts above. ALoadthat reads none gets no type, and its route takes any keys, as before. - Nothing runs in the browser to check the values: the route gets the type only (
searchTypesreturnsundefined, and TanStack then reads the query as it is).
Showing HTML the app trusts
A field of type tifa.HTML holds markup that the page shows as it is, such as an article your build turned from Markdown into HTML. Show it with the HTML component of tifa/client:
type Post struct {
Title string `json:"title"`
Body tifa.HTML `json:"body"`
}
import { HTML } from 'tifa/client'
import { page } from './route.gen'
export default function PostPage() {
const post = page.useLoaderData()
return <HTML value={post.body} as="article" className="prose" />
}
- The markup goes into the page without escaping. Use
tifa.HTMLonly for HTML you wrote or made yourself. HTML from users must be cleaned with a sanitizer first, and only then converted totifa.HTML. - In TypeScript the value has the type
HTML, notstring: TypeScript refuses it where a string goes, such as in text or with.length. Show it with<HTML>only. TypeScript does not stop it indangerouslySetInnerHTML, and on a page the server rendered it holds only a marker there.aspicks the element that holds the markup:div,article,section,main,aside,header,footer,nav,figure,blockquote,li,td,spanorp(divby default). These hold ordinary content. Elements whose content runs or is not markup, such asscript,style,iframeortextarea, would make cleaning the HTML useless, so TypeScript refuses any other name and<HTML>throws for it. The other props go to that element, exceptchildrenanddangerouslySetInnerHTML, which<HTML>leaves out also when a spread brings them. - A page the server renders carries each value once: in its markup. Its data for hydration holds a small marker in its place, and
<HTML>reads the markup back from the page. So an article is not sent twice. Navigation data and pages withSSR = falsecarry the string. - So render
<HTML value={...}>on the server every time it shows a value of the page: not only after an effect, a click or a state only the browser has, and not in a.client.tsxcomponent. Otherwise the browser throwstifa: this tifa.HTML value came with the page, which carries it only in the markup the server rendered, and the server rendered no <HTML> for it here. - Links in the markup work like a
Link: a click on a link to a page of the app shows that page through the router, without loading the whole document again, and a hover or a focus of 50 ms, or a touch, preloads it. The browser follows the link itself for a click with a modifier key or another mouse button, a link with atargetother than_self, withdownloador withrel="external", a link to another site or scheme such asmailto:, a#hashof the page that shows, a public file, a path under/assets/or/__tifa/, and a path with no page, such as an API route. Writerel="external"on a link of your site that should load the whole page, such as one to a service on the same domain that is not Tifa.<HTML>handles only the links inside its own element. YouronClickand other handlers on<HTML>run first, and one that callsevent.preventDefault()keeps the router out. tifa.HTMLcannot be a map key, a handler input or part of the session. Take astringthere and convert it after you sanitize it. ALoadorLayoutcannot return atifa.HTMLon its own: put it in a struct field.
Calling method handlers from the browser
The route.gen module of a folder with method handlers exports one function per handler, named after its method. API routes get a route.gen module too, so a page can import the handlers of any folder:
import { POST } from './route.gen'
import { TifaError } from 'tifa/client'
async function ship() {
try {
const shipment = await POST({ params: { project, order }, input: { carrier: 'SF' } })
} catch (e) {
if (e instanceof TifaError) setErrors(e.fields) // e.status, e.message, e.fields
}
}
- The function takes one object.
paramsholds the path parameters and is left out when the folder has none. Aname++folder's key is_splat. A value that would send the request to another path is refused before any request and rejects the promise: an empty value,.or..for aname+parameter, and a.or..segment or an empty segment before the end for_splat. An empty_splatis fine.inputis the handler's input and is left out when it takes none.signalaborts the request. - GET and DELETE send the input in the query string, the other methods as a JSON body, or as a multipart form when the input holds files (see Files in the input). The result is typed from the Go result, with
| undefinedfor a redirect (below):func(c, in) (Out, error)givesPromise<POSTOutput | undefined>.func(c, in) errorgivesvoid.func(c) errorwrites its own response, so its function gives back theResponseas it is, also for an error status. - A call only sends its request and, when the answer carries a session, applies it (see below). It never reloads the data of a page, on success or on failure, for any method. When the page should show what the write changed, call
router.invalidate()after it (see the example below). - An error answer throws
TifaErrorwithstatus,messageandfields(the messages of atifa.Fields, empty otherwise). A network failure throws asfetchdoes. A call from a page of an older build than the server fails with status 409, see Pages open while you deploy. - When the handler or
OnRequestreturnstifa.Redirect(url, status), the browser goes to that URL: through the router for a URL of this site, without reloading the page, and as a whole page load for another site. The new page shows what the router has for it and loads what is missing, as after any navigation. A redirect to the page that is showing stays where it is and loads nothing. It counts as the same page when the path, the hash and the query values match, whatever the order and encoding of the query. The promise resolves once the navigation has finished, toundefined, also for a handler with a result. Whether a call is redirected is only known from its answer, sinceOnRequestmay redirect any request, so the result type of every handler function with a result includesundefined. The function of a handler that writes its own response gets theResponseof the redirect (ok, with the status inX-Tifa-Redirect). A relative URL is resolved against the URL of the handler, not of the page. A 3xx the handler wrote itself throughc.Writer(), or one a proxy wrote, cannot be read in the browser and rejects the promise with anError. - A call that signs someone in or out brings the new session in its answer, and the copy of the session in the browser follows (see Sessions in the browser).
- Call these functions from event handlers or effects. Calling one while the page renders on the server throws.
route.genalso exportsPOSTInput,POSTOutputand so on for the types of each handler that has them.
The error that tifa.Redirect returns is a *tifa.RedirectError with the fields URL and Status. In OnRequest or a test, recognize it with errors.As.
To go to the page of what a handler created, return a redirect from the handler, or return the result and navigate yourself. A call reloads nothing, so the page you leave is not loaded again just before. A write the page itself shows stays on screen after the call. Ask for it with router.invalidate():
func POST(c *tifa.Ctx, in AddInput) error {
todo, err := AddTodo(in.Title)
if err != nil {
return err
}
return tifa.Redirect("/todos/"+todo.ID, http.StatusSeeOther)
}
const router = useRouter() // from @tanstack/react-router
// in the event handler, where POST returns (Todo, error):
const todo = await POST({ input: { title } })
if (todo) await router.navigate({ to: '/todos/$todo', params: { todo: todo.id } }) // undefined: redirected
Layout
A Layout lives in its folder next to the page of that folder, if there is one: the Layout function in route.go and layout.tsx wrap the page in the same folder and every page below it. layout.tsx places child routes with <Outlet />. Either may be left out: without layout.tsx the child routes render directly, and without a Layout function the Layout has no data. A Layout with no page in its folder or below it fails the build.
package project
func Layout(c *tifa.Ctx) (projects.Project, error) {
return projects.GetProject(c.Param("project"))
}
Layoutgoes inroute.go, next toLoad,SSR,Memo,Cacheand the method handlers of the same folder. Declaring it in any other file of the package, alayout.gofor example, fails the build. Aroute.gowith only aLayoutis no API route.- A Layout's
c.Parammay only read parameters of its own folder path.Layoutinapp/projects/project+/route.gomay readproject, notorder. A page'sLoadis held to its own path the same way. - When you switch between pages under the same Layout, the Layout component is not remounted and keeps its state. When a path parameter the Layout function reads changes (for example, you move to another project), the Layout remounts and its state resets. When a query parameter changes, even one it reads, the Layout loads its data again and renders it, but is not remounted and keeps its state, as TanStack Router does by default. So a filter keeps the view the visitor chose. State a component set up from the data of
Load, such as withuseState(data.x), is not reset by a new query either. Where it should follow the new data, give the component akeyfrom the value, or update the state in an effect. Pages work the same way. - Pages and Layouts can call
tifa.Use(c, project.Layout)to get the result of a Layout that wraps them, for the current request: the Layout of the same folder or of an ancestor folder, unless alayout_.tsxbetween drops it. The sameLayoutruns only once per request. Any other Layout fails the build, and so does an argument that is not a package-levelLayoutfunction, such as a closure. ALayoutfunction cannot use its own Layout, directly or through a helper. - On navigation in the browser, the navigation data request runs only the
LoadandLayoutfunctions of the listed routes. If an ancestor Layout's data is still in the cache, that Layout is not in the list and itsLayoutdoes not run this time. So do not put permission checks only in a Layout. Put them inOnRequest, or have the page'sLoaddepend on the checking Layout throughtifa.Use, so the check runs on every request. - The document shell (
<html>,<head>, assets and the script that injects data) is written as a string by the framework. React only renders the app root inside<body>, so the page is still a complete document when any level fails or returns 404. The root Layout (app/layout.tsx) can exportdocumentHeadto customize the shell, in the same format as the return value ofhead. Its tags are carried by every page, also when no route matches or the rootLayoutfails, and itshtmlAttributesare the attributes of<html>every page starts from ({ lang: 'en' }when it has none, and a route'sheadcan change them for its pages, see below). Put the site's defaulttitlehere so that the 404 page for an unmatched URL also has a title. A page's ownheadthat returns atitleoverrides it. Exporting aDocumentcomponent fails the build.
export const documentHead = {
htmlAttributes: { lang: 'zh-CN' },
meta: [{ title: 'Shop' }, { name: 'theme-color', content: '#f2f4f5' }],
links: [{ rel: 'icon', href: '/favicon.svg' }],
}
- A page's head comes from the
headreturn values of the matched routes:titleand meta tags with the same name come from the deepest route that has them, which keeps every one of them it writes (atheme-colorfor eachmedia, severalog:image), and link, style and script tags are deduplicated in route order. The framework always adds<meta charset="utf-8">and a viewport meta, and a route'sname: 'viewport'meta replaces the latter. Tag attributes are written the way React DOM writes them on the server:className,htmlFor,httpEquiv,crossOriginand so on become their HTML names. Event attributes starting withon, invalid attribute names,null,undefinedand functions are not written. Boolean attributes such asasyncanddeferare written with an empty value when true. For other attributes, boolean values are written as strings only ondata-andaria-attributes.javascript:links are replaced. Head tags do not support thestyleattribute, and using it makes rendering fail.htmlAttributesfollows the same rules. The content of style and script tags is written as is. Only the<scriptand</script(in style,<styleand</style) that would end the element are escaped, the way React DOM does it. After browser navigation and afterrouter.invalidate(), the head updates to match the new routes. - A
headcan also returnhtmlAttributes, the attributes of<html>for its pages, such as a theme class or adata-attribute. They are merged over thehtmlAttributesof the root Layout'sdocumentHeadone attribute at a time: the deepest route that gives an attribute wins,undefinedleaves it to the routes above, andnulltakes it away. Attributes are matched by the name React DOM writes, soclassNamein one route andclassin another are the same attribute.classis replaced as a whole, never merged with a value from elsewhere.styleis not supported, as on the tags of the head. They are written by the same rules as the tags of the head. After browser navigation and afterrouter.invalidate()they follow the new routes too. In the browser Tifa writes an attribute of<html>only when the value it wants for it changes, and takes away only attributes it wrote. So what a script of the page sets, such as thedarkclass of a dark mode script or thelanga translation tool changes, stays through hydration and navigation while the routes want the same value of that attribute. When that value changes, because a route sets anotherclassor a navigation leaves it and the root Layout'sclasscomes back, Tifa writes it and the class the script added is gone. Keep such a theme in an attribute no route sets, such asdata-theme, or have the script add it again. A page without SSR gets these attributes in the browser.
// app/guide/layout.tsx. Layout in route.go returns the theme of the guide.
export const head = ({ loaderData }: { loaderData?: LayoutData }) => ({
htmlAttributes: { 'data-theme': loaderData?.theme },
})
- The routes that count are those whose head is on the page. A 404 or an error below the Layout keeps the Layout's attributes, also for a URL below the Layout that no page has, since its 404 shows inside the Layout (see 404). When the Layout itself fails, its
headruns without data, so the example above leaves the root Layout'sdata-theme. - On a site with languages Tifa writes
langitself, the language of the page. AlanginhtmlAttributesfails the build there (see A site in several languages). htmlAttributesmust be an object, andpnpm typecheckreports any other value. At run time such a value fails like an error theheadthrows: the server render fails as an unexpected error (OnError, or a 500), with the message in the log, and on the page undertifa dev. In the browser, after a navigation or on a page without SSR, the router writes the error to the console and drops the whole head of that route.
Title and meta tags
Write the title and the meta tags of a page in its head export (or in documentHead of the root Layout), never as <title> or <meta> in a component. React 19 allows them in a component and moves them into the head in the browser, but Tifa writes the head of the document as a string and React renders only the app root inside <body>. So the server HTML has the tag in <body>, where crawlers and share cards do not read it, and the page can end up with two descriptions.
// not this
export default function Page() {
return <><title>Pour-over kettle</title><p>...</p></>
}
// this
export const head = () => ({ meta: [{ title: 'Pour-over kettle' }] })
tifa check, tifa build and tifa dev warn about a <title> or <meta> written as JSX, with its file and line. A <title> inside an <svg> is the tooltip of a graphic and is fine, and so is a <meta itemProp>.
A Layout without the Layouts above
Name the component file layout_.tsx instead of layout.tsx, and the Layout of the folder shows its pages without any Layout above it, the root Layout included. Only the document shell the framework writes stays around them. The storefront of examples/shop works this way: it draws its own header and footer, and none of the workbench the root Layout draws around the other pages.
app/
route.go layout.tsx the workbench: sidebar, top bar, the list of shops
projects/
project+/
route.go layout.tsx page.tsx inside the workbench
store/
layout_.tsx the storefront starts here, without the workbench
_locales/ zh-CN.json and en-US.json
route.go page.tsx the storefront
cart/
route.go page.tsx inside the storefront
- The pages below it, also those further down, do not render the Layouts above it, and their
Layoutfunctions do not run for them: not for a page, not for the navigation data request of the browser, not for the 404 of a URL below it that no page has. So their data never reaches these pages. - The
Layoutin theroute.goof the same folder gives it data as usual. The folders below it nest as usual: alayout.tsxfurther down shows inside it and itsLayoutruns. Alayout_.tsxfurther down drops it in turn, with everything above it. - What belongs to the document still applies: the root Layout's
documentHeadwith itshtmlAttributes, andOnRequest. What belongs to the Layouts above does not: theirhead, and theirErrorBoundary. When theLayoutof alayout_.tsxfails, or returnstifa.ErrNotFound, no Layout is above it to show the error, so the framework's default page shows. Its ownErrorBoundaryshows for what fails below it, as with any Layout. To show your own page when thatLayoutfails, put thelayout_.tsxone folder higher, with an<Outlet />and anErrorBoundary. - In the browser, a move between a page below it and a page outside it swaps the whole frame, and the Layouts of the new page load their data when the router has none of it yet.
- The build fails for a
layout_.tsxinapp/, which has no Layout above it, forlayout.tsxandlayout_.tsxin the same folder, and fortifa.Useof a Layout that alayout_.tsxdrops, from a page or Layout below it. It also fails for a Layout whose pages are all below alayout_.tsx, since it wraps none of them. - React Router and TanStack Router also end a name with
_to keep a route out of a Layout, but only out of the Layout of the segment before it: the root route and the Layouts further up still wrap it. Tifa'slayout_.tsxdrops every Layout above it, the root Layout too.
404
A 404 shows in the ErrorBoundary of a route (see Errors on a page), which gets it as a TifaError with status 404:
import { TifaError } from 'tifa/client'
export function ErrorBoundary({ error }: { error: unknown }) {
if (error instanceof TifaError && error.status === 404) return <p>No such order</p>
return <p>Something went wrong</p>
}
| Case | What is shown |
|---|---|
A page's Load returns tifa.ErrNotFound |
The first ErrorBoundary going up from that page. Outer Layouts are shown as usual |
A Layout function returns tifa.ErrNotFound |
The first ErrorBoundary going up from the Layout one level up |
| The URL matches no page | The first ErrorBoundary going up from the deepest Layout the URL matches, inside that Layout. The Layouts from the outermost one down to it run and show as usual: from the root, or from the layout_.tsx above it |
No route has an ErrorBoundary |
The framework's default 404 page |
The status code is 404 in all these cases, also after a navigation in the browser, whose data request answers with the data of the Layouts and status 404.
An unmatched URL whose last segment has a file extension (a dot and 1 to 8 letters or digits at the end, such as /wp-login.php) or that has a segment starting with a dot (/.env, /.git/config, /.well-known/missing) gets no 404 page. It gets the plain text 404 that a missing file under /assets/ gets, with no Load and no render, so the scanners that ask for such paths cost almost nothing. OnRequest still runs and sees tifa.ErrNotFound from next. A URL that a route matches is not affected, a catch-all route and a parameter that holds a dot (/users/john.doe for /users/{name}) included, and neither is a navigation data request. A route or a public file under /.well-known/ keeps answering.
To find the Layout of a URL that matches no page, Tifa compares the URL with the path of each Layout and page segment by segment, from the left. A literal segment beats a parameter, and a parameter beats the end of the path. The path that matches most wins, and a page counts as the Layout it is in. With these folders:
app/layout.tsx
app/teams/team+/layout.tsx
app/teams/team+/members/page.tsx
app/teams/new/page.tsx
| URL | The 404 shows inside |
|---|---|
/nowhere |
the root Layout |
/teams/blue/missing |
the team Layout, whose Layout reads c.Param("team") as blue |
/teams/blue/members/x |
the team Layout |
/teams/new/x |
the root Layout: new is a literal, so teams/new wins over teams/team+, and that page is in the root Layout |
- A page in a
name++folder takes every URL below it, so such a URL matches that page, and itsLoaddecides what to answer. OnRequestruns for a URL that matches no page with an emptyc.Pattern().next(c)runs the Layouts and returnstifa.ErrNotFound. WhenOnRequestreturnstifa.ErrNotFounditself, without callingnext, no Layout runs, and the page shows as when the outermostLayoutof that URL returnstifa.ErrNotFound: the root one, or that of thelayout_.tsxabove it.- The
ErrorBoundaryof a Layout only ever shows in place of a route below it, in the Layout'sOutlet, so it can read the Layout's data and the context its component provides. When a Layout fails, theErrorBoundaryof the Layout above shows, and when the root Layout or a Layout inlayout_.tsxfails, the framework's default page. - A
NotFoundexport inpage.tsxorlayout.tsxfails the build. Move what it shows intoErrorBoundary, undererror.status === 404. AnErrorexport fails the build too: rename it toErrorBoundary.
Errors on a page
page.tsx and layout.tsx can export ErrorBoundary, shown in place of that route when its Load or Layout fails, when a 404 shows there (see 404), or when a component below it throws:
import { TifaError } from 'tifa/client'
export function ErrorBoundary({ error }: { error: unknown }) {
if (error instanceof TifaError && error.status === 403) return <p>No access</p>
return <p>Something went wrong</p>
}
- A failed
LoadorLayoutreachesErrorBoundaryas aTifaErrorwithstatusand the public message and an emptyfields(thetifa.Errormessage, or whatOnErrorreturned). It is the same on the server and after hydration. - A route without its own
ErrorBoundaryuses the one of the closest ancestor that exports one, then the framework's default. The ancestors end at alayout_.tsx. - The status code of the page is that of the outermost failed route.
- A component that throws while the page renders on the server is an unexpected error:
OnErrorsees it once and picks the status (500 withoutOnError) and the public message. The page then renders again with that error in place of the page, as aTifaError, so the firstErrorBoundaryfrom the page up shows it inside the Layouts. If that render fails too, because theErrorBoundaryor a Layout around it throws, the error moves one route up, in place of the Layout the page is in, and so on up to the outermost Layout, the root one or alayout_.tsx. Only when the error in place of that Layout fails too does the browser get a plain error page from Go with the status and the public message. The browser hydrates the page with the error where the server put it, and does not run the route that threw again. No browser or CDN keeps such an answer (Cache-Control: no-store). The built app remembers it for 5 seconds instead: a request for the same page with the same data and session in that time gets the same answer without a render, andX-Tifa-Rendersaysmemo. Requests that wait for the page at the same time share the renders that place the error.OnErrorstill sees every request, the first with the whole error and the others with its first line and a note that it was not rendered again.tifa devremembers nothing, so a fix shows on the next reload. The stack trace shows only undertifa dev, over the page with theErrorBoundary, and the page reloads once you save a fix (seetifa dev). - A server render that uses up
ssr.vm_memoryor runs pastssr.timeout(see config.md) stops right there. Nocatch,finallyor promise handler in your code or in a library runs for it, so a page cannot catch it to show something else. The VM is replaced with a fresh one. A render that used upssr.vm_memoryrenders again with the error once, on a fresh VM, in place of the outermost Layout, since the same data would use up the memory at any level. Its answer is remembered as above. A render that ran pastssr.timeout, or found every VM busy, does not: Go answers with its plain error page at once. All the renders of one request share onessr.timeout, counted from the first, and a render with the error that runs out of it ends the tries. Code that recurses without end getsRangeError: Maximum call stack size exceeded, as in Node, which acatchcan take (see stack depth). When nothing catches it, it fails the render like any other error. - The page that shows the error gets the head of a page whose
Loadfailed. The route the error replaces runs itsheadwithout data, the routes below it add no tags, and theheadof every route above it runs again over the matches as they now are, sostatustells it that a route failed (see A site in several languages). Tags andhtmlAttributesthat a route gave for the page that did not render are not on the error page. The browser works out the same head when it hydrates. - Once the browser has taken over, a component that throws shows the nearest
ErrorBoundary, the same as a failedLoad. - The document shell stays complete whatever fails, so the page still loads its scripts and styles.