Deploy an ObjectStack server with Hono to Vercel.
- ✅ Hono adapter for fast, edge-compatible API routes
- ✅ Turso/LibSQL database driver with in-memory fallback
- ✅ Authentication with better-auth
- ✅ Security plugin for RBAC
- ✅ Optimized serverless function bundling with esbuild
- ✅ Environment-based configuration
# Install dependencies (from monorepo root)
pnpm install
# Start local development server
cd examples/vercel
pnpm devThe server will be available at http://localhost:3000/api/v1.
# Install Vercel CLI
npm i -g vercel
# Deploy from the examples/vercel directory
cd examples/vercel
vercel- Import your GitHub repository in the Vercel Dashboard
- Set the Root Directory to
examples/vercel - Configure environment variables (see below)
- Click Deploy
Configure these in your Vercel project settings:
| Variable | Description | Required | Example |
|---|---|---|---|
TURSO_DATABASE_URL |
Turso database connection URL | No* | libsql://your-db.turso.io |
TURSO_AUTH_TOKEN |
Turso authentication token | No* | eyJ... |
AUTH_SECRET |
Secret key for authentication (min 32 chars) | Yes | Generate with openssl rand -base64 32 |
*If not set, the server will use an in-memory database (data will be lost on restart).
# Install Turso CLI
curl -sSfL https://get.tur.so/install.sh | bash
# Create a new database
turso db create objectstack-vercel
# Get the database URL
turso db show objectstack-vercel --url
# Create an auth token
turso db tokens create objectstack-vercel
# Add both values to Vercel environment variablesexamples/vercel/
├── api/
│ └── [[...route]].js # Vercel serverless function entry point
├── scripts/
│ ├── bundle-api.mjs # esbuild bundler for serverless function
│ └── build-vercel.sh # Vercel build script
├── server/
│ └── index.ts # Server entrypoint with kernel bootstrap
├── objectstack.config.ts # ObjectStack configuration
├── package.json
├── tsconfig.json
├── vercel.json # Vercel deployment configuration
└── README.md
-
Build Step:
scripts/build-vercel.shruns on Vercel, which:- Builds the monorepo using turbo
- Bundles
server/index.ts→api/_handler.jsusing esbuild
-
Runtime: Vercel routes requests to
api/[[...route]].js, which:- Lazily boots the ObjectStack kernel on first request
- Delegates to the Hono adapter for request handling
- Persists kernel state across warm invocations
-
Database:
- Production: Uses Turso (edge-compatible LibSQL)
- Local dev: Falls back to in-memory driver
All ObjectStack API routes are available under /api/v1:
GET /api/v1/meta- Metadata discoveryGET /api/v1/data/:object- Query dataPOST /api/v1/data/:object- Insert recordsPATCH /api/v1/data/:object/:id- Update recordsDELETE /api/v1/data/:object/:id- Delete recordsPOST /api/v1/auth/sign-in- Authentication- And more...
# Health check
curl https://your-deployment.vercel.app/api/v1/meta
# Example API request (after authentication)
curl https://your-deployment.vercel.app/api/v1/data/users \
-H "Authorization: Bearer YOUR_TOKEN"Make sure you're running the build from the monorepo root, or that Vercel's installCommand is set correctly in vercel.json.
- Verify
TURSO_DATABASE_URLandTURSO_AUTH_TOKENare set correctly - Check Turso database is accessible from Vercel's network
- For debugging, you can temporarily use
:memory:as the database URL
- Increase
maxDurationinvercel.jsonif needed - Consider using Vercel Pro for higher limits
- ObjectStack Documentation
- Hono Vercel Deployment Guide
- Turso Documentation
- Vercel Serverless Functions
Apache-2.0