Vercel Integration
Use Vercel for auth routes, publish endpoints, and the control plane.
Auth Route
When a client subscribes to a private or presence channel, it sends a request to your auth endpoint. In a Next.js app on Vercel, this is a standard API route.
// app/api/realtime/auth/route.ts
import { signSubscription } from 'summon-flow-server-vercel';
export async function POST(req: Request) {
const session = await getSession(req);
if (!session) return new Response('Unauthorized', { status: 401 });
const body = await req.json();
const signature = signSubscription({
socketId: body.socketId,
channel: body.channelName,
secret: process.env.SUMMON_STREAM_APP_SECRET!,
});
return Response.json(signature);
}
Publish Endpoint
To publish events from your Vercel backend, send a POST request to the socket server's publish endpoint with your publish token.
await fetch('https://realtime.summonflow.com/apps/YOUR_KEY/events', {
method: 'POST',
headers: { Authorization: `Bearer ${token}` },
body: JSON.stringify({ channel, event, data }),
});
Environment Variables
SUMMON_STREAM_APP_KEY=your-app-key
SUMMON_STREAM_APP_SECRET=your-app-secret
SUMMON_STREAM_PUBLISH_TOKEN=your-publish-token