Skip to content

feat: create edge function demo #1586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Sep 6, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions demos/next-with-edge-functions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env.local
.env.development.local
.env.test.local
.env.production.local
17 changes: 17 additions & 0 deletions demos/next-with-edge-functions/netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[build]
command = "next build"
publish = ".next"

[dev]
framework = "#static"

[[plugins]]
package = "../plugin-wrapper/"

# This is a fake plugin, that makes it run npm install
[[plugins]]
package = "@netlify/plugin-local-install-core"

[[edge_functions]]
path = "/"
function = "helloOnTheEdge"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default (req, context) => context.json({firstName: "Louise", lastName: "Belcher"});
7 changes: 7 additions & 0 deletions demos/next-with-edge-functions/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module.exports = {
eslint: {
// Warning: This allows production builds to successfully complete even if
// your project has ESLint errors.
ignoreDuringBuilds: true,
},
}
13 changes: 13 additions & 0 deletions demos/next-with-edge-functions/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"react": "17.0.2",
"react-dom": "17.0.2"
}
}
53 changes: 53 additions & 0 deletions demos/next-with-edge-functions/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import Head from 'next/head'

export default function Home() {
return (
<div className="container">
<Head>
<title>Next.js with Edge functions</title>
</Head>

<main>
<p>
If you're seeing this page, that means that edge functions aren't running.
Run `netlify dev` to see an edge function in action!
</p>

</main>
<style jsx>{`
.container {
min-height: 100vh;
padding: 0 0.5rem;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}

main {
padding: 5rem 0;
flex: 1;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
`}</style>

<style jsx global>{`
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue,
sans-serif;
}

* {
box-sizing: border-box;
}
`}</style>
</div>
)
}
Binary file added demos/next-with-edge-functions/public/favicon.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions demos/next-with-edge-functions/public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
86 changes: 85 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
"demos/plugin-wrapper",
"demos/server-components",
"demos/middleware",
"demos/custom-routes"
"demos/custom-routes",
"demos/next-with-edge-functions"
]
}
4 changes: 2 additions & 2 deletions packages/next/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

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


### Bug Fixes

* 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))
- 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))

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

Expand Down