Skip to content

Commit 43a60c8

Browse files
feat: create edge function demo (#1586)
* feat: create demo for using an edge function on a next site * style: lint * chore: general cleanup * chore: more cleanup * chore: cleanup Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
1 parent 8ad8b81 commit 43a60c8

File tree

9 files changed

+210
-4
lines changed

9 files changed

+210
-4
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
21+
# debug
22+
npm-debug.log*
23+
yarn-debug.log*
24+
yarn-error.log*
25+
26+
# local env files
27+
.env.local
28+
.env.development.local
29+
.env.test.local
30+
.env.production.local
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[build]
2+
command = "next build"
3+
publish = ".next"
4+
5+
[dev]
6+
framework = "#static"
7+
8+
[[plugins]]
9+
package = "../plugin-wrapper/"
10+
11+
# This is a fake plugin, that makes it run npm install
12+
[[plugins]]
13+
package = "@netlify/plugin-local-install-core"
14+
15+
[[edge_functions]]
16+
path = "/"
17+
function = "helloOnTheEdge"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export default (req, context) => context.json({firstName: "Louise", lastName: "Belcher"});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
eslint: {
3+
// Warning: This allows production builds to successfully complete even if
4+
// your project has ESLint errors.
5+
ignoreDuringBuilds: true,
6+
},
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"private": true,
3+
"scripts": {
4+
"dev": "next dev",
5+
"build": "next build",
6+
"start": "next start"
7+
},
8+
"dependencies": {
9+
"next": "latest",
10+
"react": "17.0.2",
11+
"react-dom": "17.0.2"
12+
}
13+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import Head from 'next/head'
2+
3+
export default function Home() {
4+
return (
5+
<div className="container">
6+
<Head>
7+
<title>Next.js with Edge functions</title>
8+
</Head>
9+
10+
<main>
11+
<p>
12+
If you're seeing this page, that means that edge functions aren't running.
13+
Run `netlify dev` to see an edge function in action!
14+
</p>
15+
16+
</main>
17+
<style jsx>{`
18+
.container {
19+
min-height: 100vh;
20+
padding: 0 0.5rem;
21+
display: flex;
22+
flex-direction: column;
23+
justify-content: center;
24+
align-items: center;
25+
}
26+
27+
main {
28+
padding: 5rem 0;
29+
flex: 1;
30+
display: flex;
31+
flex-direction: column;
32+
justify-content: center;
33+
align-items: center;
34+
}
35+
`}</style>
36+
37+
<style jsx global>{`
38+
html,
39+
body {
40+
padding: 0;
41+
margin: 0;
42+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
43+
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue,
44+
sans-serif;
45+
}
46+
47+
* {
48+
box-sizing: border-box;
49+
}
50+
`}</style>
51+
</div>
52+
)
53+
}

package-lock.json

Lines changed: 85 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
"demos/plugin-wrapper",
104104
"demos/server-components",
105105
"demos/middleware",
106-
"demos/custom-routes"
106+
"demos/custom-routes",
107+
"demos/next-with-edge-functions"
107108
]
108109
}

packages/next/CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
## [1.1.1](https://github.com/netlify/next-runtime/compare/next-v1.1.0...next-v1.1.1) (2022-08-31)
44

5-
65
### Bug Fixes
76

8-
* remove Next.js as a peer dependency ([#1584](https://github.com/netlify/next-runtime/issues/1584)) ([6be4dc0](https://github.com/netlify/next-runtime/commit/6be4dc08e5339efb84e180e9ea02ce0bc6efe5b5))
7+
- remove Next.js as a peer dependency ([#1584](https://github.com/netlify/next-runtime/issues/1584))
8+
([6be4dc0](https://github.com/netlify/next-runtime/commit/6be4dc08e5339efb84e180e9ea02ce0bc6efe5b5))
99

1010
## [1.1.0](https://github.com/netlify/next-runtime/compare/next-v1.0.0...next-v1.1.0) (2022-08-22)
1111

0 commit comments

Comments
 (0)