UNPKG

@rivetkit/next-js

Version:

Next.js integration for RivetKit actors and client

31 lines 971 B
// src/mod.ts var toNextHandler = (registry, inputConfig = {}) => { inputConfig.disableDefaultServer = true; const publicUrl = process.env.NEXT_PUBLIC_SITE_URL ?? process.env.NEXT_PUBLIC_VERCEL_URL ?? `http://127.0.0.1:${process.env.PORT ?? 3e3}`; inputConfig.runnerKind = "serverless"; inputConfig.runEngine = true; inputConfig.autoConfigureServerless = { url: `${publicUrl}/api/rivet/start` }; inputConfig.noWelcome = true; const { fetch } = registry.start(inputConfig); const fetchWrapper = async (request, { params }) => { const { all } = await params; const newUrl = new URL(request.url); newUrl.pathname = all.join("/"); const newReq = new Request(newUrl, request); return await fetch(newReq); }; return { GET: fetchWrapper, POST: fetchWrapper, PUT: fetchWrapper, PATCH: fetchWrapper, HEAD: fetchWrapper, OPTIONS: fetchWrapper }; }; export { toNextHandler }; //# sourceMappingURL=mod.mjs.map