Skip to content

Commit ec07e30

Browse files
authored
Document regions config for experimental-edge (#43009)
This ensures we document the regions config for `experimental-edge`. x-ref: [slack thread](https://vercel.slack.com/archives/C0289CGVAR2/p1668624228564539) x-ref: #40881 ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm build && pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent 809303b commit ec07e30

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

docs/api-routes/edge-api-routes.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,25 @@ export default async function handler(req: NextRequest) {
106106
}
107107
```
108108

109+
### Configuring Regions (for deploying)
110+
111+
You may want to restrict your edge function to specific regions when deploying so that you can colocate near your data sources ensuring lower response times which can be achieved as shown.
112+
113+
Note: this config is available in `v12.3.2` of Next.js and up.
114+
115+
```js
116+
import { NextResponse } from 'next/server'
117+
118+
export const config = {
119+
regions: ['sfo1', 'iad1'], // defaults to 'all'
120+
}
121+
122+
export default async function handler(req: NextRequest) {
123+
const myData = await getNearbyData()
124+
return NextResponse.json(myData)
125+
}
126+
```
127+
109128
## Differences between API Routes
110129

111130
Edge API Routes use the [Edge Runtime](/docs/api-reference/edge-runtime.md), whereas API Routes use the [Node.js runtime](/docs/advanced-features/react-18/switchable-runtime.md).

0 commit comments

Comments
 (0)