Other hosts
The handler takes a Request and returns a Response (or null when the path is not under /_annotations). Anything that speaks the Fetch API can run it.
Netlify Functions
Section titled “Netlify Functions”import { createAnnotationsHandler, github } from 'starlight-annotations/server';
const handle = createAnnotationsHandler(github({ /* options */ }));
export default async (request) => (await handle(request)) ?? new Response('Not found', { status: 404 });export const config = { path: '/_annotations/*' };Vercel Functions
Section titled “Vercel Functions”import { createAnnotationsHandler, github } from 'starlight-annotations/server';
const handle = createAnnotationsHandler(github({ /* options */ }));
export async function GET(request) { return (await handle(request)) ?? new Response(null, { status: 404 }); }export const POST = GET;Add a rewrite from /_annotations/(.*) to the function in vercel.json.
Node, Express, Fastify
Section titled “Node, Express, Fastify”import express from 'express';import { createAnnotationsHandler, github } from 'starlight-annotations/server';import { toNodeMiddleware } from 'starlight-annotations/server/node';
const app = express();app.use(toNodeMiddleware(createAnnotationsHandler(github({ /* options */ }))));app.use(express.static('dist'));app.listen(3000);Astro endpoint (server output)
Section titled “Astro endpoint (server output)”With an adapter, add a catch-all endpoint:
import { createAnnotationsHandler, github } from 'starlight-annotations/server';
export const prerender = false;const handle = createAnnotationsHandler(github({ /* options */ }));
export const ALL = async ({ request }) => (await handle(request)) ?? new Response(null, { status: 404 });Your own storage
Section titled “Your own storage”Built in: GitHub, GitLab and Gitea / Forgejo. For anything else (Bitbucket, Azure DevOps, a database, a folder that something else commits), write your own.
createAnnotationsHandler takes any { storage, auth } pair. A storage has load(page) and update(page, mutate, user); an auth has user(request) and, optionally, route(...) for sign-in pages. See the server reference.