From 51fe59c0bee10fbc13a278ef91b815c1b8c91d3d Mon Sep 17 00:00:00 2001 From: lilnasy <69170106+lilnasy@users.noreply.github.com> Date: Tue, 19 Mar 2024 14:35:47 +0000 Subject: [PATCH] document typing of newly added locals field --- .../docs/en/guides/integrations-guide/vercel.mdx | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/content/docs/en/guides/integrations-guide/vercel.mdx b/src/content/docs/en/guides/integrations-guide/vercel.mdx index 41df71dc93277..c6e7e161186e9 100644 --- a/src/content/docs/en/guides/integrations-guide/vercel.mdx +++ b/src/content/docs/en/guides/integrations-guide/vercel.mdx @@ -395,6 +395,21 @@ export default defineConfig({ }); ``` +The edge middleware has access to Vercel's [`RequestContext`](https://vercel.com/docs/functions/edge-middleware/middleware-api#requestcontext) as `ctx.locals.vercel.edge`. If you’re using TypeScript, you can get proper typings by updating `src/env.d.ts` to use `EdgeLocals`: + +```ts +/// +/// + +type EdgeLocals = import('@astrojs/vercel').EdgeLocals + +declare namespace App { + interface Locals extends EdgeLocals { + // ... + } +} +``` + ### Node.js Version Support The `@astrojs/vercel` adapter supports specific Node.js versions for deploying your Astro project on Vercel. To view the supported Node.js versions on Vercel, click on the settings tab for a project and scroll down to "Node.js Version" section.