Edit this page

Get Started

⚠️ Beta Stage: Photon is currently in beta. APIs may change before stable release.

Installation

Install Photon package:

npm install @photonjs/runtime

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