Fastify on Vercel
Fastify is a web framework highly focused on providing the best developer experience with the least overhead and a powerful plugin architecture. You can deploy a Fastify app to Vercel with zero configuration using Vercel Functions.
Fastify applications on Vercel benefit from:
- Fluid compute: Pay for the CPU you use, automatic cold start reduction, optimized concurrency, background processing, and more
- Preview deployments: Test your changes in a copy of your production infrastructure
- Instant Rollback: Recover from breaking changes or bugs in milliseconds
- Vercel Firewall: Protect your applications from a wide range of threats with a robust, multi-layered security system
- Secure Compute: Create private links between your Vercel-hosted backend and other clouds
You can quickly deploy a Fastify application to Vercel by creating a Fastify app or using an existing one:
To allow Vercel to deploy your Fastify application and process web requests, your server entrypoint file should be named one of the following:
src/app.{js,mjs,cjs,ts,cts,mts}src/index.{js,mjs,cjs,ts,cts,mts}src/server.{js,mjs,cjs,ts,cts,mts}app.{js,mjs,cjs,ts,cts,mts}index.{js,mjs,cjs,ts,cts,mts}server.{js,mjs,cjs,ts,cts,mts}
For example, use the following code as an entrypoint:
import Fastify from 'fastify'
const fastify = Fastify({ logger: true })
fastify.get('/', async (request, reply) => {
return { hello: 'world' }
})
fastify.listen({ port: 3000 })Use vercel dev to run your application locally
vercel devTo deploy, connect your Git repository or use Vercel CLI:
vc deployWhen you deploy a Fastify app to Vercel, your Fastify application becomes a single Vercel Function and uses Fluid compute by default. This means your Fastify app will automatically scale up and down based on traffic.
All Vercel Functions limitations apply to the Fastify application, including the size of the application being limited to 250MB.
Learn more about deploying Fastify projects on Vercel with the following resources:
Was this helpful?