Server Frameworks
⚠️ Alpha Stage: Server adapters are in alpha. Some features may be incomplete.
Photon works with any server framework. Choose the one that fits your needs or the needs of your framework's users.
Hono (Recommended)
Ultrafast web framework designed for edge runtimes.
npm install @photonjs/hono hono
import { Hono } from 'hono'
import { apply, serve } from '@photonjs/hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello!'))
apply(app)
export default serve(app)
Best for:
- Edge deployments (Cloudflare, Deno, Bun)
- High performance applications
- Modern TypeScript projects
Express
The most popular Node.js web framework.
npm install @photonjs/express express
import express from 'express'
import { apply, serve } from '@photonjs/express'
const app = express()
app.get('/', (req, res) => res.send('Hello!'))
apply(app)
export default serve(app)
Best for:
- Existing Express applications
- Large ecosystem of middleware
- Traditional Node.js deployments
Fastify
High-performance web framework with schema validation.
npm install @photonjs/fastify fastify
import Fastify from 'fastify'
import { apply, serve } from '@photonjs/fastify'
const app = Fastify()
app.get('/', async () => ({ message: 'Hello!' }))
apply(app)
export default serve(app)
Best for:
- Performance-critical applications
- Schema validation requirements
- Plugin-based architecture
Elysia
Bun-optimized framework with end-to-end type safety.
bun add @photonjs/elysia elysia
import { Elysia } from 'elysia'
import { apply, serve } from '@photonjs/elysia'
const app = new Elysia()
app.get('/', () => 'Hello!')
apply(app)
export default serve(app)
Best for:
- Bun runtime
- Type-safe APIs
- Modern development experience
H3
Minimal and modern web framework.
npm install @photonjs/h3 h3
import { createApp, defineEventHandler } from 'h3'
import { apply, serve } from '@photonjs/h3'
const app = createApp()
app.use('/', defineEventHandler(() => 'Hello!'))
apply(app)
export default serve(app)
Best for:
- Serverless deployments
- Minimal overhead
- Universal compatibility
HatTip
Universal web framework built on Web Standards.
npm install @photonjs/hattip @hattip/core
import { createRouter } from '@hattip/router'
import { apply, serve } from '@photonjs/hattip'
const router = createRouter()
router.get('/', () => new Response('Hello!'))
apply(router)
export default serve(router)
Best for:
- Web Standards compliance
- Multi-runtime compatibility
- Future-proof applications
Runtime Package
For quick prototyping, use the runtime package with automatic fallback:
npm install @photonjs/runtime
// vite.config.ts
import { photon } from '@photonjs/runtime/vite'
export default {
plugins: [photon()] // Automatically creates Hono server
}
Framework Comparison
Framework | Performance | Ecosystem | Runtime Support | Best For |
---|---|---|---|---|
Hono Ultrafast web framework for edge runtimes | Excellent | Medium | Node.js, Cloudflare, Deno, Bun |
|
Express The most popular Node.js web framework | High | Very Large | Node.js |
|
Fastify High-performance web framework with schema validation | Very High | Large | Node.js |
|
Elysia Bun-optimized framework with end-to-end type safety | Excellent | Small | Bun, Node.js |
|
Migration
Photon makes it easy to migrate between frameworks:
// Before: Express
import express from 'express'
import { apply, serve } from '@photonjs/express'
// After: Hono
import { Hono } from 'hono'
import { apply, serve } from '@photonjs/hono'
The apply()
and serve()
functions work the same way across all frameworks.