Skip to content

Netlify

Node / BunVercel / Netlify
ConfigroutesDir stringServerlessConfig object
Route discoveryloadRoutes() at startupPre-built manifest
Build stepOptionalRequired (lacis build)
my-app/
├── netlify/
│ └── functions/
│ └── api.ts ← Netlify function entry point
├── routes/
│ ├── users/
│ │ └── index.ts
│ └── posts/
│ └── [id]/
│ └── index.ts
└── netlify.toml
// netlify/functions/api.ts
import { netlifyAdapter } from 'lacis/adapters'
import { routes, middlewares } from '../../routes/_manifest.js'
const handler = netlifyAdapter.createHandler({ routes, middlewares })
export { handler }
[build]
command = "lacis build"
publish = "public"
[[redirects]]
from = "/*"
to = "/.netlify/functions/api"
status = 200

Setting command = "lacis build" regenerates the routes manifest on every deploy automatically.

  1. Install dependencies:

    Terminal window
    npm install lacis @netlify/functions
  2. Commit your function and config:

    Terminal window
    git add netlify/ netlify.toml
    git commit -m "add lacis netlify handler"
  3. Deploy:

    Terminal window
    netlify deploy --prod

    Netlify picks up the build command from netlify.toml and regenerates the manifest automatically.

const handler = netlifyAdapter.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 })
},
},
})