Error Pages and Document
Table of Contents
- Default Error Pages
renderError()- 404 Arbitration
- HTML Document
- Head and CSP Nonce
- Data Serialization
Default Error Pages
Default error pages live under:
error/default.tsx is the fallback when a status-specific page is missing.
renderError()
Use res.renderError() when the handler intentionally returns an HTML error page.
Put the page id in the second argument or in options.page. Do not use renderError("error/404") as the first argument.
404 Arbitration
Vext does not turn every 404 into the same HTML page. The output depends on request type and route ownership.
This keeps API clients and static assets from accidentally receiving application HTML.
HTML Document
The default document file is:
Use reserved Vext tokens:
The template does not evaluate arbitrary expressions. Pass data through props, layoutData, messages, or head.
Head and CSP Nonce
Use options.head for title, meta, and link tags.
When nonce is provided, Vext applies it to generated script/data tags.
Data Serialization
props, layoutData, messages, and render metadata must be JSON-safe. Do not pass functions, class instances, streams, database connections, or raw request objects.
Vext escapes serialized data before injecting it into {vext.data}. Put user input into data fields or head objects instead of writing it directly into _document.html.