Skip to content

Vercel

Node / BunVercel / Netlify
ConfigroutesDir stringServerlessConfig object
Route discoveryloadRoutes() at startupPre-built manifest
Build stepOptionalRequired (lacis build)
my-app/
├── api/
│ └── [...slug].ts ← Vercel catch-all handler
├── routes/
│ ├── users/
│ │ └── index.ts
│ └── posts/
│ └── [id]/
│ └── index.ts
└── vercel.json
// api/[...slug].ts
import { vercelAdapter } from 'lacis/adapters'
import { routes, middlewares } from '../routes/_manifest.js'
const handler = vercelAdapter.createHandler({ routes, middlewares })
export default handler
{
"rewrites": [
{ "source": "/(.*)", "destination": "/api/slug" }
]
}
  1. Add lacis build to your build command in package.json:

    {
    "scripts": {
    "build": "lacis build"
    }
    }
  2. Commit your handler:

    Terminal window
    git add api/ vercel.json
    git commit -m "add lacis vercel handler"
  3. Deploy:

    Terminal window
    vercel deploy --prod

    Vercel runs lacis build automatically on each deploy, regenerating the routes manifest.

const handler = vercelAdapter.createHandler({
routes,
middlewares,
cors: { origin: 'https://myapp.com', credentials: true },
hooks: {
onNotFound: async (req, res) => {
res.status(404).json({ error: 'Not found', path: req.url })
},
},
})