Configuration
Configure your application for Vercel deployment inresolid.config.ts:
resolid.config.ts
Configuration Options
Set to
"vercel" for Vercel deploymentNode.js runtime version (18, 20, 22, or 24)
Additional files to include in serverless functions
Server Setup
Create your server entry file usingcreateHonoVercelServer:
src/server.ts
Server Options
Function to configure the Hono server instance with custom middleware
Function returning context object available in React Router loaders and actions
Build Output Structure
The build process generates a.vercel/output directory with:
Vercel Configuration
The build automatically generatesconfig.json with:
- Asset caching rules (1 year for immutable assets)
- Filesystem routing
- Function routing for server-rendered pages
- Response streaming support
Deployment Steps
Connect repository
Connect your Git repository to Vercel:
- Visit vercel.com/new
- Import your Git repository
- Vercel will auto-detect your framework settings
Configure build settings
Vercel should auto-detect the settings, but verify:
- Build Command:
npm run build - Output Directory:
.vercel/output - Install Command:
npm install
Environment Variables
Set environment variables in the Vercel dashboard:Automatically set by Vercel
Set to
"1" by Vercel platformProduction URL of your deployment
Vercel CLI Deployment
Deploy using the Vercel CLI:Serverless Functions
The Vercel preset automatically creates optimized serverless functions:- Functions are bundled with only necessary dependencies
- Uses Node File Trace for minimal bundle size
- Supports response streaming
- Configured with appropriate Node.js runtime
.vc-config.json specifies:
Request Utilities
Vercel provides built-in request utilities:Client IP Detection
src/server.ts
x-real-ip header provided by Vercel.
Request ID
src/server.ts
x-vercel-id header for request tracing.
Request Origin
src/server.ts
VERCEL_PROJECT_PRODUCTION_URL.
Server Bundles
For large applications, you can split server code into multiple bundles:resolid.config.ts
_site.func/- Main application function_admin.func/- Admin section function
Performance Optimization
Edge Network
Static assets are automatically distributed to Vercel’s edge network:- Assets cached at edge locations worldwide
- Immutable assets cached for 1 year
- Fast response times globally
Function Regions
Configure function regions invercel.json:
vercel.json
Monitoring
Monitor your deployment in the Vercel dashboard:- Real-time function logs
- Performance metrics
- Error tracking
- Analytics and insights
Troubleshooting
Build fails with module not found
Build fails with module not found
Ensure all dependencies are in
package.json and ssr.external is configured correctly in your Vite config.Function timeout errors
Function timeout errors
Increase function timeout in
vercel.json or optimize your server-side code.Large bundle sizes
Large bundle sizes
Use
serverBundles to split your application into smaller, route-specific functions.