Node.js Deployment
Deploy Genkit applications to any Node.js platform using Express integration. Works with Vercel, Fly.io, AWS, Render, Railway, and more.Overview
Genkit provides first-class Express.js integration through the@genkit-ai/express plugin:
- Framework agnostic - Works with any Node.js HTTP server
- Built-in streaming - Server-Sent Events (SSE) support
- Authentication - Context providers for auth
- Flexible deployment - Deploy anywhere Node.js runs
Installation
Basic Setup
1. Create Express Server
src/index.ts
2. Test Locally
Express Handler Options
Basic Usage
With Authentication
With Streaming
Streaming is enabled automatically when:- Request has
Accept: text/event-streamheader, OR - Request has
?stream=truequery parameter
Flow Server
UsestartFlowServer to automatically expose all flows:
POST /jokeFlowPOST /summarizeFlow
With Authentication
Custom Paths
Advanced Patterns
Direct Flow Invocation
Raw Streaming
Multiple Flows
CORS Configuration
Deployment Platforms
Vercel
vercel.json
Fly.io
fly.toml
Render
render.yaml
Railway
AWS Elastic Beanstalk
Heroku
Procfile
Complete Example
See the full Express integration example:js/testapps/express/src/index.ts
This example demonstrates:
- Flow via
expressHandlerwith auth - Flow without auth
- Direct flow invocation
- Raw streaming
- Context providers
Testing the Example
Durable Streaming (Beta)
Persist stream state to handle client reconnections:X-Genkit-Stream-Id header:
Production Best Practices
1. Error Handling
2. Request Validation
3. Rate Limiting
4. Timeout Handling
5. Health Checks
Monitoring
Express Middleware
Structured Logging
Troubleshooting
Request Body Undefined
Problem:request.body is undefined.
Solution: Add JSON middleware:
CORS Errors
Problem: Browser blocks requests. Solution: Enable CORS:Streaming Not Working
Problem: Streaming doesn’t start. Solution: Add query parameter or header:Next Steps
Express Plugin
Full Express plugin documentation
Cloud Run
Deploy to Google Cloud Run