You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/pages/framework-guides/deploy-a-nextjs-site.md
+6-40Lines changed: 6 additions & 40 deletions
Original file line number
Diff line number
Diff line change
@@ -43,19 +43,11 @@ filename: pages/api/hello.js
43
43
// Next.js Edge API Routes: https://nextjs.org/docs/api-routes/edge-api-routes
44
44
45
45
exportconstconfig= {
46
-
runtime:'experimental-edge',
46
+
runtime:'edge',
47
47
}
48
48
49
49
exportdefaultasyncfunction (req) {
50
-
returnnewResponse(
51
-
JSON.stringify({ name:'John Doe' }),
52
-
{
53
-
status:200,
54
-
headers: {
55
-
'Content-Type':'application/json'
56
-
}
57
-
}
58
-
)
50
+
returnResponse.json({ name:'John Doe' })
59
51
}
60
52
```
61
53
@@ -71,48 +63,22 @@ filename: pages/api/hello.ts
71
63
importtype { NextRequest } from'next/server'
72
64
73
65
exportconst config = {
74
-
runtime: 'experimental-edge',
66
+
runtime: 'edge',
75
67
}
76
68
77
69
exportdefaultasyncfunction (req:NextRequest) {
78
-
returnnewResponse(
79
-
JSON.stringify({ name: 'John Doe' }),
80
-
{
81
-
status: 200,
82
-
headers: {
83
-
'Content-Type': 'application/json'
84
-
}
85
-
}
86
-
)
70
+
returnResponse.json({ name: 'John Doe' })
87
71
}
88
72
```
89
73
90
74
{{</tab>}}
91
75
{{</tabs>}}
92
76
93
-
Next, you must configure the rest of the project to use the Edge Runtime. This can be done globally by adding the following to your `next.config.js` file:
94
-
95
-
```diff
96
-
---
97
-
filename: next.config.js
98
-
---
99
-
/** @type {import('next').NextConfig} */
100
-
const nextConfig = {
101
-
+ experimental: {
102
-
+ runtime: 'experimental-edge',
103
-
+ },
104
-
reactStrictMode: true,
105
-
swcMinify: true,
106
-
}
107
-
108
-
module.exports = nextConfig
109
-
```
110
-
111
-
Or you can opt in on individual pages by exporting the following from each page:
77
+
Next, you must configure the rest of the project to use the Edge Runtime. You can opt in on individual pages by exporting the following from each page:
0 commit comments