Rename your server entry to +server.js (we recommend to move it at your root directory), and use the standard syntax export default { fetch }.
Hono
Express.js
Fastify
H3
Elysia
// server/index.js// +server.js ////import { Hono } from 'hono'import { apply, serve } from '@photonjs/hono'import vike from '@vikejs/hono'const app = new Hono()apply(app) vike(app) export default serve(app) export default { fetch: app.fetch }
// server/index.ts// +server.tsimport type { Server } from 'vike/types'import { Hono } from 'hono'import { apply, serve } from '@photonjs/hono'import vike from '@vikejs/hono'const app = new Hono()apply(app) vike(app) export default serve(app) export default { fetch: app.fetch } satisfies Server
If you weren't using a server entry, enable Vike's built-in server instead of creating +server.js:
🚧 Server settings are now separate because values usually differ between dev and prod. If you have a use case where settings share the same value in dev and prod, then reach out and we'll create server settings that apply to both dev an prod.
Note that createServer is now built-in and can safely be removed.
// +server.jsimport { Hono } from 'hono'import vike from '@vikejs/hono'import compress from '@universal-middleware/compress'const app = new Hono()vike(app) // Add universal middlewares here (same for Express.js, Fastify, ...)vike(app, [compress()])
// +server.tsimport { Hono } from 'hono'import vike from '@vikejs/hono'import compress from '@universal-middleware/compress'const app = new Hono()vike(app) // Add universal middlewares here (same for Express.js, Fastify, ...)vike(app, [compress()])
photon.static
Replace with the prod.static setting in +server.js:
// +server.jsexport default { // ... prod: { // Serve static files automatically static: true, // Default value // Can be disabled: static: false, // Or serve from a custom folder: static: './public' }}
// +server.tsexport default { // ... prod: { // Serve static files automatically static: true, // Default value // Can be disabled: static: false, // Or serve from a custom folder: static: './public' }}
7. Typescript (optional)
If you use pageContext.runtime and TypeScript:
declare global { namespace Vike { interface Photon { interface Server { // Pick your server (for correct pageContext.runtime type) server: 'hono' // 'express' | 'fastify' | 'hattip' | 'srvx' | 'elysia' | 'h3' } }}