first commit
Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled

This commit is contained in:
Arian Tron
2026-03-10 19:37:31 +03:30
commit 61f56f997c
27684 changed files with 2784175 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
import Link from 'next/link'
import fs from 'fs'
import path from 'path'
export async function getStaticProps() {
const text = fs
.readFileSync(path.join(process.cwd(), 'world.txt'), 'utf8')
.trim()
return {
props: {
world: text,
time: new Date().getTime(),
},
revalidate: true,
}
}
export default ({ world, time }) => (
<>
<p>hello {world}</p>
<span id="anotherTime">time: {time}</span>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/something" id="something">
to something
</Link>
</>
)

View File

@@ -0,0 +1,27 @@
import { useRouter } from 'next/router'
export const getStaticProps = () => {
return {
props: {
hello: 'world',
},
}
}
export const getStaticPaths = () => {
return {
paths: ['/api-docs/first'],
fallback: true,
}
}
export default function Slug(props) {
if (useRouter().isFallback) return 'Loading...'
return (
<>
<p id="api-docs">API Docs</p>
<p id="props">{JSON.stringify(props)}</p>
</>
)
}

View File

@@ -0,0 +1,3 @@
export default function handler(req, res) {
throw new Error('lol')
}

View File

@@ -0,0 +1,4 @@
export default function handler(req, res) {
res.setPreviewData({ hello: 'world' })
res.json({ enabled: true })
}

View File

@@ -0,0 +1,17 @@
export default async function handler(req, res) {
// WARNING: don't use user input in production
// make sure to use trusted value for revalidating
let revalidated = false
try {
console.log('API: Called res.revalidate for ', req.query.pathname)
await res.revalidate(req.query.pathname, {
unstable_onlyGenerated: !!req.query.onlyGenerated,
})
revalidated = true
} catch (err) {
console.error(err)
}
res.json({
revalidated,
})
}

View File

@@ -0,0 +1,7 @@
export function getServerSideProps() {
throw new Error('lol')
}
export default function BadGssp() {
return <div />
}

View File

@@ -0,0 +1,7 @@
export function getServerSideProps() {
return { props: {} }
}
export default function BadSsr() {
throw new Error('oops')
}

View File

@@ -0,0 +1,55 @@
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
export async function getStaticPaths() {
return {
paths: [
{
params: { slug: '404-on-manual-revalidate' },
},
],
fallback: 'blocking',
}
}
export async function getStaticProps({ params }) {
await new Promise((resolve) => setTimeout(resolve, 1000))
if (process.env.NEXT_PHASE !== 'phase-production-build') {
if (params.slug === '404-on-manual-revalidate') {
return {
notFound: true,
}
}
}
return {
props: {
params,
hello: 'world',
post: params.slug,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
revalidate: false,
}
}
export default ({ post, time, params }) => {
if (useRouter().isFallback) {
return <p>hi fallback</p>
}
return (
<>
<p>Post: {post}</p>
<span id="time">time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,43 @@
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
export async function getStaticPaths() {
return {
paths: [{ params: { slug: 'a' } }, { params: { slug: 'b' } }],
fallback: 'blocking',
}
}
export async function getStaticProps({ params }) {
await new Promise((resolve) => setTimeout(resolve, 1000))
return {
props: {
params,
hello: 'world',
post: params.slug,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 1,
}
}
export default ({ post, time, params }) => {
if (useRouter().isFallback) {
return <p>hi fallback</p>
}
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,78 @@
import fs from 'fs'
import path from 'path'
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
export async function getStaticPaths() {
return {
paths: [
{
params: { slug: 'test-errors-1' },
},
{
params: { slug: 'lots-of-data' },
},
],
fallback: 'blocking',
}
}
export async function getStaticProps({ params }) {
if (params.slug === 'lots-of-data') {
return {
props: {
lotsOfData: new Array(256 * 1000).fill('a').join(''),
},
}
}
if (params.slug.startsWith('test-errors')) {
const errorFile = path.join(process.cwd(), 'error.txt')
if (fs.existsSync(errorFile)) {
const data = await fs.readFileSync(errorFile, 'utf8')
if (data.trim() === 'yes') {
throw new Error('throwing error for /blocking-fallback/' + params.slug)
}
}
}
await new Promise((resolve) => setTimeout(resolve, 1000))
console.log(`getStaticProps ${params.slug}`)
const result = {
props: {
params,
hello: 'world',
post: params.slug,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
}
// Don't add revalidate for test-manual-1 to test pure on-demand revalidation
if (params.slug !== 'test-manual-1') {
result.revalidate = 1
}
return result
}
export default ({ post, time, params }) => {
if (useRouter().isFallback) {
return <p>hi fallback</p>
}
return (
<>
<p>Post: {post}</p>
<span id="time">time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,41 @@
import React from 'react'
import Link from 'next/link'
export async function getStaticPaths() {
return {
paths: [
'/blog/post-1/comment-1',
{ params: { post: 'post-2', comment: 'comment-2' } },
],
fallback: true,
}
}
export async function getStaticProps({ params }) {
return {
props: {
post: params.post,
comment: params.comment,
time: new Date().getTime(),
},
revalidate: 2,
}
}
export default ({ post, comment, time }) => {
// we're in a loading state
if (!post) {
return <p>loading...</p>
}
return (
<>
<p>Post: {post}</p>
<p>Comment: {comment}</p>
<span>time: {time}</span>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,61 @@
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import 'firebase/firestore'
export async function getStaticPaths() {
return {
paths: [
'/blog/post-1',
{ params: { post: 'post-2' } },
'/blog/[post3]',
'/blog/post-4',
'/blog/post.1',
'/blog/post.1', // handle duplicates
],
fallback: true,
}
}
let counter = 0
export async function getStaticProps({ params }) {
if (params.post === 'post-10') {
await new Promise((resolve) => {
setTimeout(() => resolve(), 1000)
})
}
if (params.post === 'post-100') {
throw new Error('such broken..')
}
if (params.post === 'post-999') {
if (++counter < 6) {
throw new Error('try again..')
}
}
return {
props: {
params,
post: params.post,
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 10,
}
}
export default ({ post, time, params }) => {
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,24 @@
import React from 'react'
import Link from 'next/link'
export async function getStaticProps() {
return {
props: {
slugs: ['post-1', 'post-2'],
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 10,
}
}
export default ({ slugs, time }) => {
return (
<>
<p>Posts: {JSON.stringify(slugs)}</p>
<span>time: {time}</span>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,43 @@
import Link from 'next/link'
export async function getStaticProps({ params: { slug } }) {
if (slug[0] === 'delayby3s') {
await new Promise((resolve) => setTimeout(resolve, 3000))
}
return {
props: {
slug,
time: Date.now(),
},
revalidate: 1,
}
}
export async function getStaticPaths() {
return {
paths: [
{ params: { slug: ['first'] } },
'/catchall-explicit/second',
{ params: { slug: ['another', 'value'] } },
'/catchall-explicit/hello/another',
'/catchall-explicit/[first]/[second]',
{ params: { slug: ['[third]', '[fourth]'] } },
],
fallback: false,
}
}
export default function Page({ slug, time }) {
// Important to not check for `slug` existence (testing that build does not
// render fallback version and error)
return (
<>
<p id="catchall">Hi {slug.join(' ')}</p>
<p id="time">time: {time}</p>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,29 @@
import Link from 'next/link'
export async function getStaticProps({ params: { slug } }) {
return {
props: {
slug: slug || [],
},
}
}
export async function getStaticPaths() {
return {
paths: [{ params: { slug: [] } }, { params: { slug: ['value'] } }],
fallback: false,
}
}
export default ({ slug }) => {
// Important to not check for `slug` existence (testing that build does not
// render fallback version and error)
return (
<>
<p id="catchall">Catch all: [{slug.join(', ')}]</p>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,34 @@
import { useRouter } from 'next/router'
export async function getStaticProps({ params: { slug } }) {
if (slug[0] === 'delayby3s') {
await new Promise((resolve) => setTimeout(resolve, 3000))
}
return {
props: {
slug,
},
revalidate: 1,
}
}
export async function getStaticPaths() {
return {
paths: [
{ params: { slug: ['first'] } },
'/catchall/second',
{ params: { slug: ['another', 'value'] } },
'/catchall/hello/another',
],
fallback: true,
}
}
export default ({ slug }) => {
const { isFallback } = useRouter()
if (isFallback) {
return <p id="catchall">fallback</p>
}
return <p id="catchall">Hi {slug.join(' ')}</p>
}

View File

@@ -0,0 +1,24 @@
import Link from 'next/link'
export async function getStaticProps() {
return {
props: {
world: 'world',
time: new Date().getTime(),
},
}
}
export default ({ world, time }) => (
<>
<p>hello {world}</p>
<span>time: {time}</span>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/something" id="something">
to something
</Link>
</>
)

View File

@@ -0,0 +1,27 @@
import Link from 'next/link'
export async function getStaticProps({ params: { slug } }) {
return {
props: { slug },
}
}
export async function getStaticPaths() {
return {
paths: [{ params: { slug: '[first]' } }, '/dynamic/[second]'],
fallback: false,
}
}
export default ({ slug }) => {
// Important to not check for `slug` existence (testing that build does not
// render fallback version and error)
return (
<>
<p id="param">Hi {slug}!</p>{' '}
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,50 @@
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
import fs from 'node:fs/promises'
export async function getStaticPaths() {
return {
paths: [],
fallback: true,
}
}
export async function getStaticProps({ params }) {
while (true) {
try {
await fs.stat('resolve-static-props')
break
} catch (e) {}
await new Promise((resolve) => setTimeout(resolve, 100))
}
return {
props: {
params,
hello: 'world',
post: params.slug,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 1,
}
}
export default ({ post, time, params }) => {
if (useRouter().isFallback) {
return <p>hi fallback</p>
}
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,40 @@
import Link from 'next/link'
import { useRouter } from 'next/router'
export async function getStaticPaths() {
return {
paths: ['/fallback-true/first'],
fallback: true,
}
}
export async function getStaticProps({ params }) {
return {
props: {
params,
hello: 'world',
post: params.slug,
random: Math.random(),
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 2,
}
}
export default ({ post, time, params }) => {
if (useRouter().isFallback) {
return <p>hi fallback</p>
}
return (
<>
<p>Post: {post}</p>
<span>time: {time}</span>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1,106 @@
import Link from 'next/link'
export async function getStaticProps() {
return {
props: { world: 'world', time: new Date().getTime() },
// bad-prop
revalidate: 2,
}
}
const Page = ({ world, time }) => {
return (
<>
<p>hello {world}</p>
<span>time: {time}</span>
<Link href="/non-json/[p]" as="/non-json/1" id="non-json">
to non-json
</Link>
<br />
<Link href="/another?hello=world" as="/another/?hello=world" id="another">
to another
</Link>
<br />
<Link href="/something" id="something">
to something
</Link>
<br />
<Link href="/normal" id="normal">
to normal
</Link>
<br />
<Link href="/blog/[post]" as="/blog/post-1" id="post-1">
to dynamic
</Link>
<Link href="/blog/[post]" as="/blog/post-100" id="broken-post">
to broken
</Link>
<Link
href="/blog/[post]"
as="/blog/post-999"
prefetch={false}
id="broken-at-first-post"
>
to broken at first
</Link>
<br />
<Link
href="/blog/[post]/[comment]"
as="/blog/post-1/comment-1"
id="comment-1"
>
to another dynamic
</Link>
<Link href="/catchall/[...slug]" as="/catchall/first" id="to-catchall">
to catchall
</Link>
<br />
<Link href="/index" id="to-nested-index">
to nested index
</Link>
<br />
<Link href="/lang/[lang]/about?lang=en" as="/about" id="to-rewritten-ssg">
to rewritten static path page
</Link>
<br />
<Link
href="/catchall-optional/[[...slug]]"
as="/catchall-optional"
id="catchall-optional-root"
>
to optional catchall root
</Link>
<Link
href="/catchall-optional/[[...slug]]"
as="/catchall-optional/value"
id="catchall-optional-value"
>
to optional catchall page /value
</Link>
<br />
<Link href="/dynamic/[slug]" as="/dynamic/[first]" id="dynamic-first">
to dynamic [first] page
</Link>
<Link href="/dynamic/[slug]" as="/dynamic/[second]" id="dynamic-second">
to dynamic [second] page
</Link>
<br />
<Link
href="/catchall-explicit/[...slug]"
as="/catchall-explicit/[first]/[second]"
id="catchall-explicit-string"
>
to catchall-explicit [first]/[second] page
</Link>
<Link
href="/catchall-explicit/[...slug]"
as="/catchall-explicit/[third]/[fourth]"
id="catchall-explicit-object"
>
to catchall-explicit [third]/[fourth] page
</Link>
</>
)
}
export default Page

View File

@@ -0,0 +1,18 @@
import Link from 'next/link'
export async function getStaticProps() {
return {
props: { world: 'nested index' },
}
}
export default ({ world }) => {
return (
<>
<p>hello {world}</p>
<Link href="/">
<a id="home">to home</a>
</Link>
</>
)
}

View File

@@ -0,0 +1,12 @@
export default ({ lang }) => <p id="about">About: {lang}</p>
export const getStaticProps = ({ params: { lang } }) => ({
props: {
lang,
},
})
export const getStaticPaths = () => ({
paths: ['en', 'es', 'fr', 'de'].map((p) => `/lang/${p}/about`),
fallback: false,
})

View File

@@ -0,0 +1,25 @@
import React from 'react'
import Link from 'next/link'
export function getServerSideProps() {
return {
props: {
lotsOfData: new Array(256 * 1000).fill('a').join(''),
},
}
}
export default (props) => {
return (
<>
<p>lots of data returned</p>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/another" id="another">
to another
</Link>
</>
)
}

View File

@@ -0,0 +1,26 @@
import React from 'react'
import Link from 'next/link'
export async function getStaticProps({ params }) {
return {
props: {
lotsOfData: new Array(256 * 1000).fill('a').join(''),
},
revalidate: false,
}
}
export default (props) => {
return (
<>
<p>lots of data returned</p>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/another" id="another">
to another
</Link>
</>
)
}

View File

@@ -0,0 +1,21 @@
import { useRouter } from 'next/router'
export async function getStaticProps() {
return {
props: { time: new Date() },
}
}
export async function getStaticPaths() {
return { paths: [], fallback: 'blocking' }
}
const Page = ({ time }) => {
const { isFallback } = useRouter()
if (isFallback) return null
return <p>hello blocking {time.toString()}</p>
}
export default Page

View File

@@ -0,0 +1,21 @@
import { useRouter } from 'next/router'
export async function getStaticProps() {
return {
props: { time: new Date() },
}
}
export async function getStaticPaths() {
return { paths: [], fallback: true }
}
const Page = ({ time }) => {
const { isFallback } = useRouter()
if (isFallback) return null
return <p>hello {time.toString()}</p>
}
export default Page

View File

@@ -0,0 +1 @@
export default () => <p id="normal-text">a normal page</p>

View File

@@ -0,0 +1,17 @@
export function getStaticProps({ preview, previewData }) {
return {
props: {
preview: preview || false,
previewData: previewData || null,
},
}
}
export default function Page(props) {
return (
<>
<p id="page">/preview</p>
<p id="props">{JSON.stringify(props)}</p>
</>
)
}

View File

@@ -0,0 +1,34 @@
import React from 'react'
import Link from 'next/link'
import { useRouter } from 'next/router'
export async function getStaticProps({ params }) {
return {
props: {
world: 'world',
params: params || {},
time: new Date().getTime(),
random: Math.random(),
},
revalidate: false,
}
}
export default ({ world, time, params, random }) => {
return (
<>
<p>hello: {world}</p>
<span>time: {time}</span>
<div id="random">{random}</div>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/another" id="another">
to another
</Link>
</>
)
}

View File

@@ -0,0 +1,7 @@
export function getServerSideProps() {
return { props: {} }
}
export default function Page() {
return <p>/ssr</p>
}

View File

@@ -0,0 +1,28 @@
import React from 'react'
import Link from 'next/link'
export async function getStaticPaths() {
return { paths: [], fallback: true }
}
export async function getStaticProps({ params }) {
return {
props: {
user: params.user,
time: (await import('perf_hooks')).performance.now(),
},
revalidate: 10,
}
}
export default ({ user, time }) => {
return (
<>
<p>User: {user}</p>
<span>time: {time}</span>
<Link href="/" id="home">
to home
</Link>
</>
)
}

View File

@@ -0,0 +1 @@
world