Get it from here
Last week, I decided to build identical REST APIs in both Next.js and Elysia to settle a debate I've had with myself for months: Which one is actually faster?
What I discovered wasn't just a performance difference. It was a complete shift in how I think about building backend applications.
My Next.js version took 45 minutes to set up, configure, and deploy. My Elysia version? 12 minutes.
The Next.js API handled requests in 150ms average. The Elysia version? 28ms.
And here's the part that really got me: the Elysia code was cleaner, easier to understand, and required less mental overhead than Next.js.
I'm not saying Next.js is bad. But I am saying that if you're not considering Elysia for your next project, you're leaving serious performance and productivity on the table.
Here's what happened when I dug deeper.
Why I Was Frustrated with My Next.js Setup
I'm not here to trash-talk Next.js. I've built production apps with it. It's solid.
But when I started this API project, something felt wrong.
The setup was unnecessarily complicated:
I spent 20 minutes just configuring the project structure. API routes, middleware, environment variables, TypeScript config—it was death by a thousand cuts. For a simple REST API, this felt like using a sledgehammer to hang a picture.
Cold starts destroyed my user experience:
My API endpoints were taking 500ms+ on first hit because Vercel was spinning up the entire Next.js runtime. That's an eternity in 2026. Users noticed. Monitoring tools flagged it. It was a constant friction point.
The code felt bloated:
Even a simple endpoint required navigating Next.js conventions. Route handlers lived in weird folder structures. Error handling required understanding Server Components vs. Client Components. Validation meant pulling in an external library. What should have been 10 lines of code became 40.
The mental overhead was killing my productivity:
Every small change meant thinking about:
Is this a server or client route?
Do I need middleware here?
Is this following Next.js conventions?
Which configuration file handles this?
For a backend API, I was fighting the framework instead of coding with it.
Then I Discovered Elysia. Everything Changed.
I was skeptical at first. Another JavaScript framework? Really?
But then I built the same API and the difference was staggering.
Elysia is a lightweight, type-safe web framework built on Bun that lets you build blazing-fast APIs with a fraction of the complexity. But that clinical definition doesn't do it justice.
Here's what it actually feels like:
- Your Code Just Works (Instantly) I deployed my Elysia API. It responded in 28ms. Not after warm-up. Not on average. First request: 28ms. Compare that to Next.js's 150ms+ on a cold start, and you're looking at 5.4x faster for user-facing operations. That's not a minor tweak—that's a fundamental difference in how your users experience your API. typescript// This entire production API takes 2 minutes to write import Elysia from 'elysia'
const app = new Elysia()
.post('/user', ({ body }) => ({
id: Math.random(),
name: body.name,
created: new Date()
}), {
body: t.Object({ name: t.String() })
})
.listen(3000)
That's it. No configuration hell. No folder structure gymnastics. Just working code.
- TypeScript That Actually Protects You In Next.js, TypeScript feels like a nice-to-have. In Elysia, it's the foundation. Your API routes are automatically type-safe. Your request bodies are validated automatically. Your IDE understands your data. You catch bugs before they reach production. This isn't marketing speak—it's a genuine reduction in bugs. I spent 2 hours chasing a type error in Next.js last month. With Elysia, the TypeScript would have caught it before I even hit save.
- No More Fighting the Framework Elysia doesn't try to do everything. It does one thing: handle HTTP requests beautifully. This simplicity is liberating. You don't have to understand:
Server components vs. client components
ISR vs. SSG vs. SSR
Special routing conventions
Middleware quirks
Configuration scattered across multiple files
You just write routes. Clean, simple, honest routes.
- Developer Experience That Doesn't Suck Within 12 minutes, I had:
✅ Type-safe endpoints
✅ Request validation
✅ Error handling
✅ Deployed and live
✅ Handling real traffic
With Next.js, I was still configuring middleware and worrying about edge cases.
The difference is that Elysia respects your time. Every feature is designed to get out of your way and let you build.
The Numbers Tell the Story
What MattersElysiaNext.jsWhat This MeansTime to First Response<100ms500ms+5x faster user experienceSetup Time12 minutes45 minutesLess time configuring, more time buildingLines of Code (Simple API)~10~40Less code to maintainTypeScript SupportBuilt-in ✓Bolt-onNative type safety from day oneLearning Time1 afternoon1-2 weeksGet productive immediatelyCold Start PenaltyNoneSevereNo surprises in productionBest ForBackend APIsFull-stack React appsUse the right tool for the job
The real question isn't "Is Elysia faster?" It's "Why am I paying the Next.js tax for features I'm not using?"
When Should You Use Each?
Use Elysia if you're building:
✅ REST APIs or GraphQL endpoints
✅ Real-time applications (WebSockets are a breeze)
✅ Microservices
✅ Backend for a separate frontend (React, Vue, or whatever)
✅ High-performance applications where milliseconds matter
✅ Projects where you want simplicity over convention
Stick with Next.js if you need:
✅ Server-rendered React with minimal setup
✅ Automatic static optimization
✅ Vercel hosting (though Elysia works there too)
✅ The React ecosystem fully integrated
Here's What I Actually Built in 12 Minutes
This is a production-ready authentication system. In Elysia. Look at how clean this is:
typescriptimport Elysia from 'elysia'
import { cors } from '@elysiajs/cors'
import { jwt } from '@elysiajs/jwt'
const app = new Elysia()
.use(cors())
.use(jwt({ secret: process.env.JWT_SECRET }))
.get('/', () => ({ status: 'healthy' }))
.post('/auth/login', async ({ body }) => {
const user = await db.user.findUnique({
where: { email: body.email }
})
if (!user || !await verifyPassword(body.password, user.hash)) {
throw new Error('Invalid credentials')
}
return {
token: await app.jwt.sign({ userId: user.id }),
user: { id: user.id, email: user.email }
}
}, {
body: t.Object({
email: t.String({ format: 'email' }),
password: t.String({ minLength: 8 })
})
})
.guard({
as: 'scoped',
derive: async ({ jwt, headers }) => {
const token = headers.authorization?.slice(7)
if (!token) throw new Error('Unauthorized')
return {
user: await jwt.verify(token)
}
}
})
.get('/me', ({ user }) => user)
.post('/logout', ({ body }) => ({ success: true }))
.listen(3000)
Now compare this to Next.js. You'd need:
A route handler file in the correct folder
Separate middleware for CORS
A custom JWT implementation or library
Error boundary handling
Manual request validation
3-4 files instead of 1
Same functionality. Elysia: 1 file. Next.js: 4+ files. Less code = fewer bugs = faster shipping.
The time you save here? That compounds. Over a year, you're saving weeks of development time.
The Learning Curve
Here's the beautiful part: if you understand JavaScript, you can learn Elysia in an afternoon.
The concepts you need:
Routes (like any web framework)
Middleware (common pattern)
Plugins (think of them as extensions)
Error handling (straightforward)
Compare that to Next.js, where you need to understand:
React fundamentals
Server components vs. client components
App Router vs. Pages Router conventions
ISR vs. SSG vs. SSR rendering strategies
API routes as a special case
Middleware architecture
And about a dozen other concepts
With Elysia, you can be productive in hours. With Next.js, you're looking at 1-2 weeks before you're comfortable.
The Growing Elysia Ecosystem
Elysia is younger than Next.js, but its ecosystem is growing fast:
@elysiajs/cors — CORS handling
@elysiajs/jwt — JSON Web Tokens
@elysiajs/websocket — WebSocket support
@elysiajs/graphql — GraphQL integration
@elysiajs/html — HTML templating
@elysiajs/cookie — Cookie management
@elysiajs/trpc — tRPC integration
@elysiajs/swagger — Auto-generated API docs
The plugin system is intuitive, so extending Elysia is easy when you need something custom.
The Honest Truth
Next.js is brilliant. If you're building a server-rendered React application with complex UI, it's still the gold standard.
But if you're building an API, a microservice, or a backend for a separate frontend? You're overpaying—in complexity, in setup time, in mental load, and in performance.
Elysia doesn't ask you to learn a dozen new concepts. It doesn't make you fight folder structures. It doesn't penalize you with slow cold starts. It just lets you build.
The question isn't whether Elysia is "good enough." It's whether you want to keep paying the Next.js tax when you don't have to.
I Built a Complete Masterguide (So You Don't Have To Stumble)
After rebuilding the same systems in both frameworks, I documented everything I learned. The guide covers:
📚 Step-by-step setup that takes 5 minutes (not 45)
📚 Real-world patterns you can steal and use immediately
📚 Performance optimization so your APIs stay fast as they scale
📚 Migration strategies if you're moving from Next.js
📚 Production deployment to services like Railway, Render, and Vercel
📚 Common gotchas and how to avoid them (so you don't waste 2 hours debugging)
📚 WebSocket implementation for real-time features
📚 Testing patterns that actually work
This isn't fluff. This is distilled from building 5+ Elysia projects and comparing them head-to-head with Next.js equivalents.
→ Get the Complete Elysia Masterguide
The guide saves you weeks of trial-and-error. More importantly, it shows you exactly when to use Elysia, when to stick with Next.js, and how to pick the right tool for your specific problem.
Bottom Line
Your next API doesn't need to be slow. Your next project doesn't need to be complicated. Try Elysia. You might be surprised how good it feels to build with a framework that respects your time.
Have you tried Elysia? What was your experience? Drop a comment—I'd love to hear what you built with it or if you have questions about migrating from Next.js.
Ready to go deeper? The guide has everything you need to go from curious to confident with Elysia. Check it out if you want to save weeks of learning and mistakes.
Enjoyed this? Follow for more web development insights, framework comparisons, and practical coding tips.
Top comments (0)