Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
565c5b20
Unverified
Commit
565c5b20
authored
Dec 16, 2023
by
Lee Robinson
Committed by
GitHub
Dec 16, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs: small tweaks (#59638)
Just some random cleanup I wanted to do.
parent
2e14537f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
10 deletions
+48
-10
not-found.mdx
...02-app/02-api-reference/02-file-conventions/not-found.mdx
+2
-0
use-params.mdx
docs/02-app/02-api-reference/04-functions/use-params.mdx
+1
-1
01-vitest.mdx
...ges/01-building-your-application/07-testing/01-vitest.mdx
+1
-1
invalid-redirect-gssp.mdx
errors/invalid-redirect-gssp.mdx
+44
-8
No files found.
docs/02-app/02-api-reference/02-file-conventions/not-found.mdx
View file @
565c5b20
...
...
@@ -83,6 +83,8 @@ export default async function NotFound() {
}
```
If
you
need
to
use
Client
Component
hooks
like
`usePathname`
to
display
content
based
on
the
path
,
you
must
fetch
data
on
the
client
-
side
instead
.
## Version History
|
Version
|
Changes
|
...
...
docs/02-app/02-api-reference/04-functions/use-params.mdx
View file @
565c5b20
...
...
@@ -11,7 +11,7 @@ description: API Reference for the useParams hook.
import { useParams } from 'next/navigation'
export default function ExampleClientComponent() {
const params = useParams()
const params = useParams
<{ tag: string; item: string }>
()
// Route -> /shop/[tag]/[item]
// URL -> /shop/shoes/nike-air-max-97
...
...
docs/03-pages/01-building-your-application/07-testing/01-vitest.mdx
View file @
565c5b20
---
title: Setting up Vitest with Next.js
nav_title:
J
est
nav_title:
Vit
est
description: Learn how to set up Next.js with Vitest and React Testing Library - two popular unit testing libraries.
source: app/building-your-application/testing/vitest
---
...
...
errors/invalid-redirect-gssp.mdx
View file @
565c5b20
...
...
@@ -10,23 +10,59 @@ The `redirect` value returned from your `getStaticProps` or `getServerSideProps`
Make
sure
you
return
the
proper
values
for
the
`redirect`
value
.
```js filename="pages/blog/[slug].js"
export const getStaticProps = ({ params }) => {
if (params.slug === 'deleted-post') {
```tsx filename="pages/index.tsx" switcher
import type { InferGetStaticPropsType, GetStaticProps } from 'next'
type Repo = {
name: string
stargazers_count: number
}
export const getStaticProps = (async (context) => {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
if (!repo) {
return {
redirect: {
permanent:
true, // or fals
e
destination: '/
some-location
',
permanent:
false, // or tru
e
destination: '/
404
',
},
}
}
return {
props: {},
return { props: { repo } }
}) satisfies GetStaticProps<{
repo: Repo
}>
export default function Page({
repo,
}: InferGetStaticPropsType<typeof getStaticProps>) {
return repo.stargazers_count
}
```
```jsx filename="pages/index.js" switcher
export async function getStaticPaths() {
const res = await fetch('https://api.github.com/repos/vercel/next.js')
const repo = await res.json()
if (!repo) {
return {
redirect: {
permanent: false, // or true
destination: '/404',
},
}
}
return { props: { repo } }
}
export default function Page(props) {}
export default function Page({ repo }) {
return repo.stargazers_count
}
```
## Useful Links
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment