Get Started
Photon is a next-generation server toolkit designed for library and framework developers who need universal server capabilities.
Who is Photon for?
Photon is primarily designed for:
- Framework developers building universal web frameworks
- Library authors creating server-agnostic tools
- Platform builders needing multi-runtime support
- Advanced developers who want maximum flexibility
If you're looking to build a simple web app, consider using frameworks built with Photon like Vike instead.
Installation
Install Photon core:
npm install @photonjs/core
Choose a server adapter:
npm install @photonjs/hono
Basic Configuration
// vite.config.ts
import { photon } from '@photonjs/core/vite'
export default {
plugins: [
photon({
server: './src/server.ts'
})
]
}
Create Your Server
Choose your preferred server framework. This example shows how to create a universal server that works across runtimes:
With Hono
// src/server.ts
import { Hono } from 'hono'
import { apply, serve } from '@photonjs/hono'
const app = new Hono()
app.get('/', (c) => c.text('Hello Photon!'))
apply(app)
export default serve(app)
With Express
// src/server.ts
import express from 'express'
import { apply, serve } from '@photonjs/express'
const app = express()
app.get('/', (req, res) => {
res.send('Hello Photon!')
})
apply(app)
export default serve(app)
With Fastify
// src/server.ts
import Fastify from 'fastify'
import { apply, serve } from '@photonjs/fastify'
const app = Fastify()
app.get('/', async () => {
return { message: 'Hello Photon!' }
})
apply(app)
export default serve(app)
Development
Start the development server:
npm run dev
Your app will be available at http://localhost:3000
with hot module replacement.
Building
Build for production:
npm run build
Building a Framework
If you're building a framework with Photon, consider:
- Universal middleware - Create middleware that works across all server adapters
- Runtime detection - Handle different deployment targets gracefully
- Type safety - Leverage Photon's TypeScript support
- Documentation - Help your users understand deployment options
Next Steps
Learn Core Concepts
→Understand Photon's philosophy and architecture
Framework Integration
→Learn how to integrate Photon into your framework
Server Frameworks
→Choose the right server framework for your needs
Deployment Options
→Deploy your framework users' apps anywhere
Examples
↗Study real-world integration examples
Get Help
↗Ask questions and get support from the community
Note: As Photon is in alpha, expect API changes and potential breaking updates. Follow the GitHub repository for the latest developments.