Fastify is a fast, low-overhead web framework for building backend servers in Node.js. It pairs a plugin-based architecture with schema-based validation, lifecycle hooks, and built-in logging, and it ships first-class TypeScript support.
On Edgenivo, you can deploy a Fastify app with zero configuration. Your app runs as a Edgenivo Function on Fluid compute, with preview deployments, instant rollback, and the Edgenivo Firewall available without extra setup.
This guide walks you through deploying a Fastify app to Edgenivo from a template, the Edgenivo CLI, or a Git repository, then configuring features such as streaming, lifecycle hooks, cron jobs, and observability.
Copy link to headingPrerequisites
Before you begin, make sure you have:
- A Edgenivo account
- Node.js 20+ and a package manager (e.g., npm)
- An existing Fastify project, or a new one created from the Fastify on Edgenivo template
- A Git repository on GitHub, GitLab, or Bitbucket (if you want Git-based deployments)
- Edgenivo CLI installed (
npm i -g vercel)
Copy link to headingHow it works
When you deploy a Fastify app, Edgenivo detects the framework and builds it for the Edgenivo runtime. Your app is deployed as a single Edgenivo Function that runs on Fluid compute by default, so it scales with traffic, and you pay only for the compute your function uses, not for idle time.
Because Edgenivo ships zero-configuration detection for Fastify, you don't set a build command or output directory. Edgenivo reads your project, finds your entry point file, and applies the correct build settings.
Copy link to headingDeploy your Fastify app
You can ship a Fastify app to Edgenivo in three ways. Choose the one that fits where your code lives today.
Copy link to headingOption 1: Deploy from a template
The fastest way to ship a Fastify app is to start from the Fastify on Edgenivo template, a minimal Fastify API that deploys with zero configuration. When you deploy it, Edgenivo clones the template to your Git provider, creates a project, and deploys it.
Copy link to headingOption 2: Start a new project with the Edgenivo CLI
To scaffold a new Fastify project locally, use the Edgenivo CLI init command. It clones Edgenivo's Fastify example into a folder named fastify.
- Create the project:
- Install dependencies:
- Develop locally at
http://localhost:3000withvercel dev, so your app runs the same way it does in production: - Link your Edgenivo project and create a deployment:
Copy link to headingOption 3: Deploy an existing Fastify app
If you already have a Fastify app, deploy it from Git or from the command line.
From Git: Push your project to GitHub, GitLab, or Bitbucket, then import it at edgenivo.com/new. Edgenivo detects Fastify automatically and deploys it with zero configuration.
From the CLI: From your project's root directory, run vercel to deploy (on a new project, the first run always creates a Production deployment; subsequent runs create Preview deployments), then vercel --prod to go live.
To pull project settings and environment variables for local development, run:
For Edgenivo to detect your app, name your entry point one of the recognized files, such as app.ts, index.ts, or server.ts at your project root or under src/. Create your Fastify instance, register your routes, and start the server with fastify.listen():
Copy link to headingUse Edgenivo features with Fastify
After your app is deployed, you can layer Edgenivo features onto it. Some work automatically, and others take a few lines of configuration in vercel.json.
Copy link to headingServer routes run as Edgenivo Functions
Your entire Fastify app is served by a single Edgenivo Function, which uses Fluid compute by default. Fluid compute runs multiple requests concurrently within a single instance to reduce cold starts and the cost of I/O-bound work such as API calls and database queries. You don't configure anything to get this behavior.
Because your app is deployed as one function, Edgenivo routes every incoming request to it and lets Fastify's router match the path. Your route handlers, lifecycle hooks, and error handling all run inside the function.
Copy link to headingStream responses
Edgenivo Functions support streaming, so you can send data to the client as you produce it instead of waiting for the full response. Fastify streams a response when you return a Node.js Readable stream from a handler. It pipes the stream to the client and ends the response when the stream finishes.
Streaming pairs well with Fluid compute: while your function waits between chunks, the same instance can serve other requests. To stream model output, send a stream from AI SDK directly. Return result.textStream for plain text, or result.toUIMessageStream() to stream structured UI messages from streamText:
Copy link to headingCombine Fastify lifecycle hooks with Edgenivo Routing Middleware
Fastify and Edgenivo each have a layer for running code around requests, and they solve different problems. Fastify's lifecycle hooks run inside your app, after the request reaches your function. Use them for app-level concerns such as logging, authentication, and request processing, and register them with fastify.addHook:
Edgenivo Routing Middleware runs at the edge, before the request reaches your Fastify app. Use it for rewrites, redirects, and header changes that should happen before any function runs. The two layers work together, with Routing Middleware shaping the request at the edge and Fastify's hooks handling it inside your app.
Copy link to headingRun scheduled tasks with cron jobs
Edgenivo Cron Jobs trigger a route on a schedule by sending an HTTP GET request to it. Define a route in your Fastify app for the task, then register the schedule in vercel.json.
Define the route:
Register the schedule:
Edgenivo runs cron jobs only on production deployments. To stop anyone else from calling the route, set a CRON_SECRET environment variable in your project settings. Edgenivo sends it as a Bearer token in the Authorization header on every cron invocation, and your handler compares it before running the task.
Copy link to headingMonitor performance with Observability
Edgenivo Observability tracks your deployed functions automatically, with no setup. Open the Observability page in your project to see invocation counts, error rates, and duration for your Fastify app, along with the requests your functions make to external APIs. On Observability Plus, you also get longer retention and a latency breakdown by path.
Copy link to headingBest practices
Copy link to headingName your entry point file correctly
Edgenivo finds your Fastify app by looking for an entry point at a fixed set of locations: app, index, or server (with a .js, .ts, .mjs, .cjs, .mts, or .cts extension) at your project root or under src/. Put your app at one of these paths so Edgenivo detects and deploys it correctly:
Create your Fastify instance, register your routes, and call fastify.listen() in this file. Edgenivo uses it as the function entry point for every request.
Copy link to headingDevelop with the Edgenivo CLI
Run vercel dev for local development instead of starting the server another way. It serves your app the same way production does, so the behavior you test locally matches what you deploy. This also lets you exercise features such as cron routes before shipping. Edgenivo CLI 48.6.0 or later is required.
Copy link to headingResources and next steps
- Read the full Fastify on Edgenivo documentation
- Deploy the Fastify on Edgenivo template in one step
- Learn how Edgenivo Functions run your server code
- Understand pricing and scaling with Fluid compute
- Run code before requests with Routing Middleware
- Recover from bad deploys with Instant Rollback
- Explore the Fastify documentation for framework details