Skip to content

Commit

Permalink
edge prerendering on Cloudflare ⚡
Browse files Browse the repository at this point in the history
- deleted `not-found.tsx` per cloudflare/next-on-pages#413 and cloudflare/next-on-pages#174
- added `export const runtime = 'edge';` to all `layout.tsx` files
  • Loading branch information
adamstambouli committed Jan 23, 2024
1 parent ac0e367 commit 4b66eb1
Show file tree
Hide file tree
Showing 22 changed files with 3,210 additions and 3,462 deletions.
3 changes: 3 additions & 0 deletions app/context/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { CounterProvider } from 'app/context/counter-context';
import React from 'react';
import ContextClickCounter from './context-click-counter';

export const runtime = 'edge';

const title = 'Client Context';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/error-handling/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { ClickCounter } from '#/ui/click-counter';
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Error Handling';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/hooks/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { ClickCounter } from '#/ui/click-counter';
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Hooks';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/isr/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Incremental Static Regeneration (ISR)';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
11 changes: 7 additions & 4 deletions app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ import Byline from '#/ui/byline';
import { GlobalNav } from '#/ui/global-nav';
import { Metadata } from 'next';

export const runtime = 'edge';

export const metadata: Metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title: {
default: 'Next.js App Router',
template: '%s | Next.js App Router',
default: 'Next.js App Router on Cloudflare Pages',
template: '%s | Next.js App Router on Cloudflare Pages',
},
description:
'A playground to explore new Next.js App Router features such as nested layouts, instant loading states, streaming, and component level data fetching.',
openGraph: {
title: 'Next.js App Router Playground',
title: 'Next.js App Router Playground on Cloudflare Pages',
description:
'A playground to explore new Next.js App Router features such as nested layouts, instant loading states, streaming, and component level data fetching.',
images: [`/api/og?title=Next.js App Router`],
images: [`/api/og?title=Next.js App Router on Cloudflare Pages`],
},
twitter: {
card: 'summary_large_image',
Expand Down
3 changes: 3 additions & 0 deletions app/layouts/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { ClickCounter } from '#/ui/click-counter';
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Nested Layouts';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/loading/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ import { TabGroup } from '#/ui/tab-group';
import { notFound } from 'next/navigation';
import React from 'react';

export const runtime = 'edge';

const title = 'Loading';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
13 changes: 0 additions & 13 deletions app/not-found.tsx

This file was deleted.

3 changes: 3 additions & 0 deletions app/not-found/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ import { ClickCounter } from '#/ui/click-counter';
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Not Found';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/parallel-routes/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export const runtime = 'edge';

const title = 'Parallel Routes';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/route-groups/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';

export const runtime = 'edge';

const title = 'Route Groups';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/snippets/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export const runtime = 'edge';

const title = 'Snippets';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/ssg/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { Tab } from '#/ui/tab';
import React from 'react';
import { RandomPostTab } from './random-post-tab';

export const runtime = 'edge';

const title = 'Static Data';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/ssr/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Dynamic Data';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/streaming/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Streaming';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
3 changes: 3 additions & 0 deletions app/styling/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { TabGroup } from '#/ui/tab-group';
import React from 'react';

export const runtime = 'edge';

const title = 'Styling';

export const metadata = {
metadataBase: new URL('https://app-playground-on.pages.dev'),
title,
openGraph: {
title,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"vercel": "30.2.1"
},
"devDependencies": {
"@cloudflare/next-on-pages": "1.8.5",
"@tailwindcss/forms": "0.5.3",
"@tailwindcss/typography": "0.5.9",
"@types/ms": "0.7.31",
Expand Down
Loading

0 comments on commit 4b66eb1

Please sign in to comment.