8000 feat(examples): use experimental edge runtime with grafbase (#42992) · vercel/next.js@0440404 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0440404

Browse files
authored
feat(examples): use experimental edge runtime with grafbase (#42992)
This PR adds the experimental runtime as shown in a guide that links to this example. ## 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 533c242 commit 0440404

File tree

5 files changed

+7
-9
lines changed

5 files changed

+7
-9
lines changed

examples/with-grafbase/README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ This example shows to use [Grafbase](https://grafbase.com) with Next.js. This ex
44

55
## Demo
66

7-
You can see a demo of this online at [https://grafbase-with-nextjs-rsc.grafbase-vercel.dev](https://grafbase-with-nextjs-rsc.grafbase-vercel.dev).
7+
You can see a demo of this online at [https://nextjs-rsc-demo.grafbase-vercel.dev](https://nextjs-rsc-demo.grafbase-vercel.dev).
88

9-
## Deploy
9+
## Deploy to Vercel
1010

11-
First deploy this to Grafbase to get your backend API URL and Key:
12-
13-
[![Deploy to Grafbase](https://grafbase.com/button)](https://grafbase.com/new/configure?template=NextExample&source=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-grafbase)
14-
15-
Then deploy this example using [Vercel](https://vercel.com):
11+
Make sure to provide your `GRAFBASE_API_URL` and `GRAFBASE_API_KEY` to Vercel as environment variables when deploying.
1612

1713
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fvercel%2Fnext.js%2Ftree%2Fcanary%2Fexamples%2Fwith-grafbase&env=GRAFBASE_API_URL,GRAFBASE_API_KEY)
1814

examples/with-grafbase/app/layout.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Link from 'next/link'
55
import { graphql } from '../gql'
66
import { grafbase } from '../lib/grafbase'
77

8+
export const revalidate = 0
9+
810
const GetAllPostsDocument = graphql(/* GraphQL */ `
911
query GetAllPosts($first: Int!) {
1012
postCollection(first: $first) {

examples/with-grafbase/app/posts/[slug]/page.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { graphql } from '../../../gql'
22
import { grafbase } from '../../../lib/grafbase'
33

4-
export const revalidate = 3600
5-
64
const GetPostBySlugDocument = graphql(/* GraphQL */ `
75
query GetPostBySlug($slug: String!) {
86
post(by: { slug: $slug }) {

examples/with-grafbase/lib/grafbase.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ export const grafbase = new GraphQLClient(
77
headers: {
88
'x-api-key': process.env.GRAFBASE_API_KEY as string,
99
},
10+
fetch,
1011
}
1112
)

examples/with-grafbase/next.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const nextConfig = {
33
reactStrictMode: true,
44
experimental: {
55
appDir: true,
6+
runtime: 'experimental-edge',
67
},
78
}
89

0 commit comments

Comments
 (0)
0