Framework Adapters

Fastify

Native Fastify plugin adapter

Fastify#

Surf provides a native Fastify plugin that registers all routes with proper serialization and SSE support.

typescript
import Fastify from 'fastify'
import { createSurf } from '@surfjs/core'
import { fastifyPlugin } from '@surfjs/core/fastify'
ย 
const surf = await createSurf({
name: 'Fastify App',
commands: { /* ... */ },
})
ย 
const app = Fastify()
app.register(fastifyPlugin(surf))
ย 
app.listen({ port: 3000 })

๐Ÿ’ก Tip: The Fastify adapter handles SSE streaming natively by writing directly to the raw Node response.