Nitro on Vercel
Nitro is a full-stack framework with TypeScript-first support. It includes filesystem routing, code-splitting for fast startup, built-in caching, and multi-driver storage. It enables deployments from the same codebase to any platform with output sizes under 1MB.
You can deploy a Nitro app to Vercel with zero configuration.
To get started with Nitro on Vercel, use the following Nitro template to deploy to Vercel with zero configuration:
Vercel deployments can integrate with your git provider to generate preview URLs for each pull request you make to your Nitro project.
When you deploy a Nitro app to Vercel, you can use Vercel specific features such as Incremental Static Regeneration (ISR), preview deployments, Fluid compute, Observability, and Vercel firewall with zero or minimum configuration.
ISR allows you to create or update content without redeploying your site. ISR has three main benefits for developers: better performance, improved security, and faster build times.
With on-demand revalidation, you can purge the cache for an ISR route whenever you want, foregoing the time interval required with background revalidation.
To revalidate a path to a prerendered function:
Create an Environment Variable to store a revalidation secret by:
- Using the command:
terminalopenssl rand -base64 32
- Or generating a secret to create a random value.
Update your configuration to use the revalidation secret as follows:
nitro.config.tsexport default defineNitroConfig({ vercel: { config: { bypassToken: process.env.VERCEL_BYPASS_TOKEN, }, }, });
You can revalidate a path to a prerendered function by making a
GET
orHEAD
request to that path with a header ofx-prerender-revalidate: bypassToken
When the prerendered function endpoint is accessed with this header set, the cache will be revalidated. The next request to that function will return a fresh response.
To have more control over ISR caching, you can pass an options object to the isr
route rule as shown below:
export default defineNitroConfig({
routeRules: {
'/products/**': {
isr: {
allowQuery: ['q'],
passQuery: true,
},
},
},
});
By default, query parameters are ignored by cache unless you specify them in
the allowQuery
array.
The following options are available:
Option | Type | Description |
---|---|---|
expiration | number | false | The expiration time, in seconds, before the cached asset is re-generated by invoking the serverless function. Setting the value to false (or isr: true in the route rule) will cause it to never expire. |
group | number | Group number of the asset. Use this to revalidate multiple assets at the same time. |
allowQuery | string[] | undefined | List of query string parameter names that will be cached independently. If you specify an empty array, query values are not considered for caching. If undefined , each unique query value is cached independently. For wildcard /** route rules, url is always added. |
passQuery | boolean | When true , the query string will be present on the request argument passed to the invoked function. The allowQuery filter still applies. |
With Vercel Observability, you can view detailed performance insights broken down by route and monitor function execution performance. This can help you identify bottlenecks and optimization opportunities.
Nitro (>=2.12) generates routing hints for functions observability insights, providing a detailed view of performance broken down by route.
To enable this feature, ensure you are using a compatibility date of 2025-07-15
or later.
export default defineNitroConfig({
compatibilityDate: '2025-07-15', // or "latest"
});
Framework integrations can use the ssrRoutes
configuration to declare SSR
routes. For more information, see
#3475.
When you deploy a Nitro app to Vercel, your server routes automatically become Vercel Functions and use Fluid compute by default.
Learn more about deploying Nitro projects on Vercel with the following resources:
Was this helpful?