DEV Community

Alex Spinov
Alex Spinov

Posted on

Nitro Has a Free Universal Server Engine — Build APIs That Run on Node, Deno, Cloudflare, and Bun

Why Nitro?

Nitro is the server engine behind Nuxt 3. It builds once, deploys anywhere — Node.js, Deno, Cloudflare Workers, Bun, AWS Lambda, Vercel, Netlify.

npx giget@latest nitro my-api
cd my-api && npm install && npm run dev
Enter fullscreen mode Exit fullscreen mode

File-Based API Routes

routes/
  index.ts          -> GET /
  users/index.ts    -> GET /users
  users/[id].ts     -> GET /users/:id
  users/index.post.ts -> POST /users
Enter fullscreen mode Exit fullscreen mode
// routes/users/[id].ts
export default defineEventHandler(async (event) => {
  const id = getRouterParam(event, 'id')
  const user = await db.query('SELECT * FROM users WHERE id = $1', [id])
  return user
})
Enter fullscreen mode Exit fullscreen mode
// routes/users/index.post.ts
export default defineEventHandler(async (event) => {
  const body = await readBody(event)
  const user = await db.query(
    'INSERT INTO users (name, email) VALUES ($1, $2) RETURNING *',
    [body.name, body.email]
  )
  return user
})
Enter fullscreen mode Exit fullscreen mode

Deploy Anywhere

# Node.js
npx nitro build
node .output/server/index.mjs

# Cloudflare Workers
NITRO_PRESET=cloudflare npx nitro build

# Deno Deploy
NITRO_PRESET=deno-deploy npx nitro build

# Bun
NITRO_PRESET=bun npx nitro build
Enter fullscreen mode Exit fullscreen mode

Built-in Features

  • Auto-imports (no manual imports needed)
  • File-based routing
  • KV storage (unified API for Redis, filesystem, etc.)
  • Scheduled tasks (cron)

- WebSocket support

Need to extract data from any website at scale? I build custom web scrapers — 77 production scrapers running on Apify Store. Email me at spinov001@gmail.com for a tailored solution.

Top comments (0)