DEV Community

Alex Spinov
Alex Spinov

Posted on

Nitro Has a Free API — The Universal Server Engine Behind Nuxt and Beyond

What if your server framework worked the same way on Node.js, Cloudflare Workers, Deno, Bun, and AWS Lambda — with zero config changes?

Nitro is the universal server engine that powers Nuxt 3 — but you can use it standalone for any project.

Why Nitro Matters

Every deployment target has its own API surface. Node uses req/res, Cloudflare has fetch, Lambda has event/context. Nitro abstracts all of them:

  • Write once, deploy everywhere — same code runs on 15+ platforms
  • Auto-imports — no manual import statements needed
  • File-based routing — drop a file in routes/, get an endpoint
  • Built-in storage — unified key-value API across Redis, filesystem, Cloudflare KV
  • Hot module replacement — instant dev server reload

Quick Start

# Create a Nitro project
npx giget@latest nitro my-api
cd my-api && npm install && npm run dev
Enter fullscreen mode Exit fullscreen mode

Create an API route:

// routes/hello.ts
export default defineEventHandler((event) => {
  const name = getQuery(event).name || "World";
  return { message: `Hello, ${name}!` };
});
Enter fullscreen mode Exit fullscreen mode

That's it. Visit http://localhost:3000/hello?name=Dev and you get JSON back.

Deploy Anywhere

# Deploy to Cloudflare Workers
NITRO_PRESET=cloudflare npx nitro build

# Deploy to Vercel
NITRO_PRESET=vercel npx nitro build

# Deploy to AWS Lambda
NITRO_PRESET=aws-lambda npx nitro build
Enter fullscreen mode Exit fullscreen mode

Built-in Storage Layer

// routes/cache.ts
export default defineEventHandler(async (event) => {
  const storage = useStorage("cache");
  await storage.setItem("visits", (await storage.getItem("visits") || 0) + 1);
  return { visits: await storage.getItem("visits") };
});
Enter fullscreen mode Exit fullscreen mode

Works with Redis, Cloudflare KV, filesystem — swap drivers without changing code.

Real Use Case

A developer team maintained 4 separate API codebases — one for each cloud provider their clients required. After switching to Nitro, they consolidated to a single codebase. Deployment to any platform became a one-line preset change. Maintenance effort dropped by 75%.

When to Use Nitro

✅ APIs that need multi-platform deployment
✅ Edge-first applications
✅ Microservices with universal storage needs
✅ Any project that might change hosting later

❌ Monolithic apps tied to one platform
❌ Apps needing deep platform-specific features


Need custom data pipelines or scraping solutions? Check out my Apify actors or email me at spinov001@gmail.com for custom solutions.

Top comments (0)