Netlify
How it differs from Node/Bun
Section titled “How it differs from Node/Bun”| Node / Bun | Vercel / Netlify | |
|---|---|---|
| Config | routesDir string | ServerlessConfig object |
| Route discovery | loadRoutes() at startup | Pre-built manifest |
| Build step | Optional | Required (lacis build) |
Project structure
Section titled “Project structure”my-app/├── netlify/│ └── functions/│ └── api.ts ← Netlify function entry point├── routes/│ ├── users/│ │ └── index.ts│ └── posts/│ └── [id]/│ └── index.ts└── netlify.tomlFunction handler
Section titled “Function handler”// netlify/functions/api.tsimport { netlifyAdapter } from 'lacis/adapters'import { routes, middlewares } from '../../routes/_manifest.js'
const handler = netlifyAdapter.createHandler({ routes, middlewares })
export { handler }netlify.toml
Section titled “netlify.toml”[build] command = "lacis build" publish = "public"
[[redirects]] from = "/*" to = "/.netlify/functions/api" status = 200Setting command = "lacis build" regenerates the routes manifest on every deploy automatically.
Deploy flow
Section titled “Deploy flow”-
Install dependencies:
Terminal window npm install lacis @netlify/functions -
Commit your function and config:
Terminal window git add netlify/ netlify.tomlgit commit -m "add lacis netlify handler" -
Deploy:
Terminal window netlify deploy --prodNetlify picks up the build command from
netlify.tomland regenerates the manifest automatically.
Optional config
Section titled “Optional config”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 }) }, },})