Unverified Commit f2603289 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

BREAKING CHANGE: Enable newNextLinkBehavior (#41459)

- Enable newNextLinkBehavior. See #36436 
- Run next/link codemod on test suite

Note that from when this lands on apps trying canary will need to run
the new-link codemod in order to upgrade.
Ideally we have to detect `<a>` while rendering the new link and warn
for it.
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent f5cb7bd8
......@@ -19,6 +19,30 @@ Codemods are transformations that run on your codebase programmatically. This al
## Next.js 13
### `new-link`
Safely removes `<a>` from `next/link` or adds `legacyBehavior` prop.
For example:
```jsx
export default function Page() {
return (
<Link href="/about">
<a>About Us</a>
</Link>
)
}
```
Transforms into:
```jsx
export default function Page() {
return <Link href="/about">About Us</Link>
}
```
### `next-image-to-legacy-image`
Safely migrates existing Next.js 10, 11, 12 applications importing `next/image` to the renamed `next/legacy/image` import in Next.js 13.
......
......@@ -233,7 +233,7 @@ import Link from 'next/link'
export default function IndexPage(props) {
return (
<Link href="/another" locale="fr">
<a>To /fr/another</a>
To /fr/another
</Link>
)
}
......@@ -279,7 +279,7 @@ import Link from 'next/link'
export default function IndexPage(props) {
return (
<Link href="/fr/another" locale={false}>
<a>To /fr/another</a>
To /fr/another
</Link>
)
}
......
......@@ -35,9 +35,7 @@ For example, using `/about` will automatically become `/docs/about` when `basePa
export default function HomePage() {
return (
<>
<Link href="/about">
<a>About Page</a>
</Link>
<Link href="/about">About Page</Link>
</>
)
}
......
......@@ -31,19 +31,13 @@ function Home() {
return (
<ul>
<li>
<Link href="/">
<a>Home</a>
</Link>
<Link href="/">Home</Link>
</li>
<li>
<Link href="/about">
<a>About Us</a>
</Link>
<Link href="/about">About Us</Link>
</li>
<li>
<Link href="/blog/hello-world">
<a>Blog Post</a>
</Link>
<Link href="/blog/hello-world">Blog Post</Link>
</li>
</ul>
)
......@@ -56,6 +50,7 @@ export default Home
- `href` - The path or URL to navigate to. This is the only required prop. It can also be an object, see [example here](/docs/api-reference/next/link.md#with-url-object)
- `as` - Optional decorator for the path that will be shown in the browser URL bar. Before Next.js 9.5.3 this was used for dynamic routes, check our [previous docs](https://nextjs.org/docs/tag/v9.5.2/api-reference/next/link#dynamic-routes) to see how it worked. Note: when this path differs from the one provided in `href` the previous `href`/`as` behavior is used as shown in the [previous docs](https://nextjs.org/docs/tag/v9.5.2/api-reference/next/link#dynamic-routes).
- [`legacyBehavior`](#if-the-child-is-a-tag) - Changes behavior so that child must be `<a>`. Defaults to `false`.
- [`passHref`](#if-the-child-is-a-custom-component-that-wraps-an-a-tag) - Forces `Link` to send the `href` property to its child. Defaults to `false`
- `prefetch` - Prefetch the page in the background. Defaults to `true`. Any `<Link />` that is in the viewport (initially or through scroll) will be preloaded. Prefetch can be disabled by passing `prefetch={false}`. When `prefetch` is set to `false`, prefetching will still occur on hover. Pages using [Static Generation](/docs/basic-features/data-fetching/get-static-props.md) will preload `JSON` files with the data for faster page transitions. Prefetching is only enabled in production.
- [`replace`](#replace-the-url-instead-of-push) - Replace the current `history` state instead of adding a new url into the stack. Defaults to `false`
......@@ -78,7 +73,7 @@ function Posts({ posts }) {
{posts.map((post) => (
<li key={post.id}>
<Link href={`/blog/${encodeURIComponent(post.slug)}`}>
<a>{post.title}</a>
{post.title}
</Link>
</li>
))}
......@@ -89,6 +84,22 @@ function Posts({ posts }) {
export default Posts
```
## If the child is `<a>` tag
```jsx
import Link from 'next/link'
function Legacy() {
return (
<Link href="/about" legacyBehavior>
<a>About Us</a>
</Link>
)
}
export default Legacy
```
## If the child is a custom component that wraps an `<a>` tag
If the child of `Link` is a custom component that wraps an `<a>` tag, you must add `passHref` to `Link`. This is necessary if you’re using libraries like [styled-components](https://styled-components.com/). Without this, the `<a>` tag will not have the `href` attribute, which hurts your site's accessibility and might affect SEO. If you're using [ESLint](/docs/basic-features/eslint.md#eslint-plugin), there is a built-in rule `next/link-passhref` to ensure correct usage of `passHref`.
......@@ -103,9 +114,8 @@ const RedLink = styled.a`
`
function NavLink({ href, name }) {
// Must add passHref to Link
return (
<Link href={href} passHref>
<Link href={href} passHref legacyBehavior>
<RedLink>{name}</RedLink>
</Link>
)
......@@ -119,7 +129,7 @@ export default NavLink
## If the child is a functional component
If the child of `Link` is a functional component, in addition to using `passHref`, you must wrap the component in [`React.forwardRef`](https://reactjs.org/docs/react-api.html#reactforwardref):
If the child of `Link` is a functional component, in addition to using `passHref` and `legacyBehavior`, you must wrap the component in [`React.forwardRef`](https://reactjs.org/docs/react-api.html#reactforwardref):
```jsx
import Link from 'next/link'
......@@ -136,7 +146,7 @@ const MyButton = React.forwardRef(({ onClick, href }, ref) => {
function Home() {
return (
<Link href="/about" passHref>
<Link href="/about" passHref legacyBehavior>
<MyButton />
</Link>
)
......@@ -162,7 +172,7 @@ function Home() {
query: { name: 'test' },
}}
>
<a>About us</a>
About us
</Link>
</li>
<li>
......@@ -172,7 +182,7 @@ function Home() {
query: { slug: 'my-post' },
}}
>
<a>Blog Post</a>
Blog Post
</Link>
</li>
</ul>
......@@ -195,7 +205,7 @@ The default behavior of the `Link` component is to `push` a new URL into the `hi
```jsx
<Link href="/about" replace>
<a>About us</a>
About us
</Link>
```
......@@ -205,6 +215,6 @@ The default behavior of `Link` is to scroll to the top of the page. When there i
```jsx
<Link href="/#hashid" scroll={false}>
<a>Disables scrolling to the top</a>
Disables scrolling to the top
</Link>
```
......@@ -156,11 +156,7 @@ export default function Page(props) {
<h1>Page: {router.query.slug}</h1>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>Increase count</button>
<Link href="/one">
<a>one</a>
</Link> <Link href="/two">
<a>two</a>
</Link>
<Link href="/one">one</Link> <Link href="/two">two</Link>
</div>
)
}
......
......@@ -78,15 +78,11 @@ export default function Home() {
import Link from 'next/link'
export default function Home() {
return (
<Link href="/blog">
<a>blog</a>
</Link>
)
return <Link href="/blog">blog</Link>
}
```
Update any import statements, switch `to` to `href`, and add an `<a>` tag as a child of the element.
Update any import statements, switch `to` to `href`.
## Data Fetching
......
......@@ -34,7 +34,7 @@ import Link from 'next/link'
export default function App() {
return (
<Link href="/about">
<a>About</a>
About
</Link>
)
}
......
......@@ -63,18 +63,14 @@ function Home() {
return (
<ul>
<li>
<Link href="/post/abc">
<a>Go to pages/post/[pid].js</a>
</Link>
<Link href="/post/abc">Go to pages/post/[pid].js</Link>
</li>
<li>
<Link href="/post/abc?foo=bar">
<a>Also goes to pages/post/[pid].js</a>
</Link>
<Link href="/post/abc?foo=bar">Also goes to pages/post/[pid].js</Link>
</li>
<li>
<Link href="/post/abc/a-comment">
<a>Go to pages/post/[pid]/[comment].js</a>
Go to pages/post/[pid]/[comment].js
</Link>
</li>
</ul>
......
......@@ -47,19 +47,13 @@ function Home() {
return (
<ul>
<li>
<Link href="/">
<a>Home</a>
</Link>
<Link href="/">Home</Link>
</li>
<li>
<Link href="/about">
<a>About Us</a>
</Link>
<Link href="/about">About Us</Link>
</li>
<li>
<Link href="/blog/hello-world">
<a>Blog Post</a>
</Link>
<Link href="/blog/hello-world">Blog Post</Link>
</li>
</ul>
)
......@@ -89,7 +83,7 @@ function Posts({ posts }) {
{posts.map((post) => (
<li key={post.id}>
<Link href={`/blog/${encodeURIComponent(post.slug)}`}>
<a>{post.title}</a>
{post.title}
</Link>
</li>
))}
......@@ -118,7 +112,7 @@ function Posts({ posts }) {
query: { slug: post.slug },
}}
>
<a>{post.title}</a>
{post.title}
</Link>
</li>
))}
......
......@@ -66,9 +66,7 @@ import Link from 'next/link'
export default function Home() {
return (
<nav>
<Link href="/about">
<a>About</a>
</Link>
<Link href="/about">About</Link>
</nav>
)
}
......@@ -183,9 +181,7 @@ import Link from 'next/link'
export default function Home() {
return (
<nav>
<Link href="/about">
<a>About</a>
</Link>
<Link href="/about">About</Link>
</nav>
)
}
......
......@@ -11,6 +11,8 @@ The minimum Node.js version has been bumped from 12.22.0 to 14.0.0, since 12.x h
The `next/image` import was renamed to `next/legacy/image`. The `next/future/image` import was renamed to `next/image`.
A [codemod is available](/docs/advanced-features/codemods.md#next-image-to-legacy-image) to safely and automatically rename your imports.
The `next/link` child can no longer be `<a>`. Add the `legacyBehavior` prop to use the legacy behavior or remove the `<a>` to upgrade. A [codemod is available](/docs/advanced-features/codemods.md#new-link) to automatically upgrade your code.
## Upgrading to 12.2
If you were using Middleware prior to `12.2`, please see the [upgrade guide](https://nextjs.org/docs/messages/middleware-upgrade-guide) for more information.
......
import { loadEnvConfig } from '@next/env'
import { resolve, join } from 'path'
import loadConfig from '../../server/config'
import { NextConfigComplete } from '../../server/config-shared'
import type { NextConfigComplete } from '../../server/config-shared'
import { PHASE_TEST } from '../../shared/lib/constants'
import loadJsConfig from '../load-jsconfig'
import * as Log from '../output/log'
......
......@@ -556,8 +556,7 @@ export const defaultConfig: NextConfig = {
// TODO: change default in next major release (current v12.1.5)
legacyBrowsers: true,
browsersListForSwc: false,
// TODO: change default in next major release (current v12.1.5)
newNextLinkBehavior: false,
newNextLinkBehavior: true,
cpus: Math.max(
1,
(Number(process.env.CIRCLE_NODE_TOTAL) ||
......
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default () => (
<div>
<Link href="/hmr/error-in-gip">
<a id="error-in-gip-link">Bad Page</a>
<Link href="/hmr/error-in-gip" id="error-in-gip-link">
Bad Page
</Link>
</div>
)
......@@ -4,7 +4,7 @@ export default function IndexPage() {
return (
<div>
<Link href="/about" prefetch>
<a>To About Page</a>
To About Page
</Link>
</div>
)
......
......@@ -3,9 +3,7 @@ import Link from 'next/link'
export default function NoPrefetchPage() {
return (
<div>
<Link href="/about">
<a>No prefetch</a>
</Link>
<Link href="/about">No prefetch</Link>
</div>
)
}
......@@ -4,7 +4,7 @@ export default function PrefetchFalsePage() {
return (
<div>
<Link href="/about" prefetch={false}>
<a>Prefetch set to false</a>
Prefetch set to false
</Link>
</div>
)
......
......@@ -2,8 +2,6 @@ import Link from 'next/link'
export default () => (
<div>
<Link href="/dynamic/no-chunk">
<a>No Chunk</a>
</Link>
<Link href="/dynamic/no-chunk">No Chunk</Link>
</div>
)
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default () => (
<div>
<Link href="/hmr/error-in-gip">
<a id="error-in-gip-link">Bad Page</a>
<Link href="/hmr/error-in-gip" id="error-in-gip-link">
Bad Page
</Link>
</div>
)
......@@ -4,7 +4,7 @@ export default function IndexPage() {
return (
<div>
<Link href="/about" prefetch>
<a>To About Page</a>
To About Page
</Link>
</div>
)
......
......@@ -3,9 +3,7 @@ import Link from 'next/link'
export default function NoPrefetchPage() {
return (
<div>
<Link href="/about">
<a>No prefetch</a>
</Link>
<Link href="/about">No prefetch</Link>
</div>
)
}
......@@ -4,7 +4,7 @@ export default function PrefetchFalsePage() {
return (
<div>
<Link href="/about" prefetch={false}>
<a>Prefetch set to false</a>
Prefetch set to false
</Link>
</div>
)
......
......@@ -2,8 +2,6 @@ import Link from 'next/link'
export default () => (
<div>
<Link href="/dynamic/no-chunk">
<a>No Chunk</a>
</Link>
<Link href="/dynamic/no-chunk">No Chunk</Link>
</div>
)
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function HomePage() {
return (
<>
<Link href="/dashboard">
<a id="to-dashboard">To Dashboard</a>
<Link href="/dashboard" id="to-dashboard">
To Dashboard
</Link>
</>
)
......
......@@ -10,34 +10,34 @@ export default function Page({ params }) {
<p id="page">/blog/[author]</p>
<p id="params">{JSON.stringify(params)}</p>
<p id="date">{Date.now()}</p>
<Link href="/blog/tim">
<a id="author-1">/blog/tim</a>
<Link href="/blog/tim" id="author-1">
/blog/tim
</Link>
<br />
<Link href="/blog/seb">
<a id="author-2">/blog/seb</a>
<Link href="/blog/seb" id="author-2">
/blog/seb
</Link>
<br />
<Link href="/blog/styfle">
<a id="author-3">/blog/styfle</a>
<Link href="/blog/styfle" id="author-3">
/blog/styfle
</Link>
<br />
<Link href="/blog/tim/first-post">
<a id="author-1-post-1">/blog/tim/first-post</a>
<Link href="/blog/tim/first-post" id="author-1-post-1">
/blog/tim/first-post
</Link>
<br />
<Link href="/blog/seb/second-post">
<a id="author-2-post-1">/blog/seb/second-post</a>
<Link href="/blog/seb/second-post" id="author-2-post-1">
/blog/seb/second-post
</Link>
<br />
<Link href="/blog/styfle/first-post">
<a id="author-3-post-1">/blog/styfle/first-post</a>
<Link href="/blog/styfle/first-post" id="author-3-post-1">
/blog/styfle/first-post
</Link>
<br />
<Link href="/dynamic-no-gen-params/first">
<a id="dynamic-no-params">/dynamic-no-gen-params/first</a>
<Link href="/dynamic-no-gen-params/first" id="dynamic-no-params">
/dynamic-no-gen-params/first
</Link>
<br />
</>
......
......@@ -6,13 +6,13 @@ export default function Page({ params }) {
<p id="page">/dynamic-no-gen-params</p>
<p id="params">{JSON.stringify(params)}</p>
<Link href="/dynamic-no-gen-params/second">
<a id="dynamic-no-params-again">/dynamic-no-gen-params/second</a>
<Link href="/dynamic-no-gen-params/second" id="dynamic-no-params-again">
/dynamic-no-gen-params/second
</Link>
<br />
<Link href="/blog/styfle">
<a id="to-blog">/blog/styfle</a>
<Link href="/blog/styfle" id="to-blog">
/blog/styfle
</Link>
<br />
</>
......
......@@ -4,13 +4,16 @@ export default function Page() {
return (
<>
<div>
<Link href="/catch-all/this/is/a/test">
<a id="to-catch-all">To catch-all</a>
<Link href="/catch-all/this/is/a/test" id="to-catch-all">
To catch-all
</Link>
</div>
<div>
<Link href="/catch-all-optional/this/is/a/test">
<a id="to-catch-all-optional">To optional catch-all</a>
<Link
href="/catch-all-optional/this/is/a/test"
id="to-catch-all-optional"
>
To optional catch-all
</Link>
</div>
</>
......
......@@ -4,13 +4,13 @@ export default function Page() {
return (
<div>
<div>
<Link href="/internal/test/rewrite">
<a id="navigate-rewrite">Navigate Rewrite</a>
<Link href="/internal/test/rewrite" id="navigate-rewrite">
Navigate Rewrite
</Link>
</div>
<div>
<Link href="/internal/test/redirect">
<a id="navigate-redirect">Navigate Redirect</a>
<Link href="/internal/test/redirect" id="navigate-redirect">
Navigate Redirect
</Link>
</div>
</div>
......
......@@ -6,8 +6,8 @@ export default function Page({ params }) {
return (
<>
<h1 id={`render-id-${params.id}`}>{nanoid()}</h1>{' '}
<Link href={`/link-hard-push/${other}`}>
<a id="link">To {other}</a>
<Link href={`/link-hard-push/${other}`} id="link">
To{other}
</Link>
</>
)
......
......@@ -6,8 +6,8 @@ export default function Page({ params }) {
return (
<>
<h1 id={`render-id-${params.id}`}>{nanoid()}</h1>{' '}
<Link href={`/link-hard-replace/${other}`} replace>
<a id="link">To {other}</a>
<Link href={`/link-hard-replace/${other}`} replace id="link">
To{other}
</Link>
</>
)
......
......@@ -5,11 +5,11 @@ export default function Page() {
return (
<>
<h1 id="render-id">{nanoid()}</h1>
<Link href="/link-hard-replace" replace>
<a id="self-link">Self Link</a>
<Link href="/link-hard-replace" replace id="self-link">
Self Link
</Link>
<Link href="/link-hard-replace/subpage" replace>
<a id="subpage-link">Subpage</a>
<Link href="/link-hard-replace/subpage" replace id="subpage-link">
Subpage
</Link>
</>
)
......
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function Page() {
return (
<Link href="/link-hard-replace" replace>
<a id="back-link">Self Link</a>
<Link href="/link-hard-replace" replace id="back-link">
Self Link
</Link>
)
}
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function Page() {
return (
<Link href="/with-id">
<a id="link">With ID</a>
<Link href="/with-id" id="link">
With ID
</Link>
)
}
......@@ -5,11 +5,11 @@ export default function Page() {
return (
<>
<h1 id="render-id">{nanoid()}</h1>
<Link href="/link-soft-replace" replace>
<a id="self-link">Self Link</a>
<Link href="/link-soft-replace" replace id="self-link">
Self Link
</Link>
<Link href="/link-soft-replace/subpage" replace>
<a id="subpage-link">Subpage</a>
<Link href="/link-soft-replace/subpage" replace id="subpage-link">
Subpage
</Link>
</>
)
......
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function Page() {
return (
<Link href="/link-soft-replace" replace>
<a id="back-link">Self Link</a>
<Link href="/link-soft-replace" replace id="back-link">
Self Link
</Link>
)
}
......@@ -6,8 +6,9 @@ export default function Page() {
<Link
href="/dashboard/deployments/info/[id]"
as="/dashboard/deployments/info/123"
id="link-to-info-123"
>
<a id="link-to-info-123">To info 123</a>
To info 123
</Link>
</>
)
......
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export const TabNavItem = ({ children, href }) => {
return (
<Link href={href}>
<a style={{ margin: '10px', display: 'block' }}>{children}</a>
<Link href={href} style={{ margin: '10px', display: 'block' }}>
{children}
</Link>
)
}
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function Page(props) {
return (
<Link href="/app-linking">
<a id="app-link">To Pages Page</a>
<Link href="/app-linking" id="app-link">
To Pages Page
</Link>
)
}
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Page() {
return (
<>
<Link href="/redirect/a">
<a id="redirect-a">To Dashboard through /redirect/a</a>
<Link href="/redirect/a" id="redirect-a">
To Dashboard through /redirect/a
</Link>
</>
)
......
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Page() {
return (
<>
<Link href="/redirect-middleware-to-dashboard">
<a id="redirect-middleware">To Dashboard through /redirect/a</a>
<Link href="/redirect-middleware-to-dashboard" id="redirect-middleware">
To Dashboard through /redirect/a
</Link>
</>
)
......
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function Page() {
return (
<Link href="/rewritten-to-dashboard">
<a id="link">To Dashboard Rewritten</a>
<Link href="/rewritten-to-dashboard" id="link">
To Dashboard Rewritten
</Link>
)
}
......@@ -4,8 +4,8 @@ export default function Page() {
return (
<>
<h1 id="first-page">hello from same-layout/first</h1>
<Link href="/same-layout/second">
<a id="link">To Second</a>
<Link href="/same-layout/second" id="link">
To Second
</Link>
</>
)
......
......@@ -4,8 +4,8 @@ export default function Page() {
return (
<>
<h1 id="second-page">hello from same-layout/second</h1>
<Link href="/same-layout/first">
<a id="link">To First</a>
<Link href="/same-layout/first" id="link">
To First
</Link>
</>
)
......
......@@ -3,8 +3,8 @@ export default function Page() {
return (
<>
<p id="other-page">Other Page</p>
<Link href="/template/clientcomponent">
<a id="link">To Page</a>
<Link href="/template/clientcomponent" id="link">
To Page
</Link>
</>
)
......
......@@ -4,8 +4,8 @@ export default function Page() {
return (
<>
<p id="page">Page</p>
<Link href="/template/clientcomponent/other">
<a id="link">To Other</a>
<Link href="/template/clientcomponent/other" id="link">
To Other
</Link>
</>
)
......
......@@ -3,8 +3,8 @@ export default function Page() {
return (
<>
<p id="other-page">Other Page</p>
<Link href="/template/servercomponent">
<a id="link">To Page</a>
<Link href="/template/servercomponent" id="link">
To Page
</Link>
</>
)
......
......@@ -4,8 +4,8 @@ export default function Page() {
return (
<>
<p id="page">Page</p>
<Link href="/template/servercomponent/other">
<a id="link">To Other</a>
<Link href="/template/servercomponent/other" id="link">
To Other
</Link>
</>
)
......
......@@ -5,8 +5,8 @@ export default function Page() {
return (
<>
<h1 id="render-id">{nanoid()}</h1>
<Link href="/navigation">
<a id="link">To Navigation</a>
<Link href="/navigation" id="link">
To Navigation
</Link>
</>
)
......
......@@ -2,8 +2,8 @@ import Link from 'next/link'
export default function Page(props) {
return (
<Link href="/pages-linking">
<a id="pages-link">To App Page</a>
<Link href="/pages-linking" id="pages-link">
To App Page
</Link>
)
}
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Page(props) {
return (
<>
<Link href="/exists-but-not-routed">
<a id="link-to-rewritten-path">Exists but not routed</a>
<Link href="/exists-but-not-routed" id="link-to-rewritten-path">
Exists but not routed
</Link>
</>
)
......
......@@ -3,8 +3,8 @@ export default function HomePage() {
return (
<>
<p>
<Link href="/a/">
<a id="to-a-trailing-slash">To a with trailing slash</a>
<Link href="/a/" id="to-a-trailing-slash">
To a with trailing slash
</Link>
</p>
</>
......
......@@ -8,8 +8,8 @@ export default function LinkPage({ searchParams }) {
<>
<h3 id="query">query:{id}</h3>
<div>
<Link href={`/next-api/link?id=${id + 1}`}>
<a id="next_id">next id</a>
<Link href={`/next-api/link?id=${id + 1}`} id="next_id">
next id
</Link>
</div>
<Nav />
......
......@@ -4,18 +4,18 @@ export default function Nav() {
return (
<>
<div>
<Link href={'/next-api/link'}>
<a id="goto-next-link">next link</a>
<Link href={'/next-api/link'} id="goto-next-link">
next link
</Link>
</div>
<div>
<Link href={'/streaming-rsc'}>
<a id="goto-streaming-rsc">streaming rsc</a>
<Link href={'/streaming-rsc'} id="goto-streaming-rsc">
streaming rsc
</Link>
</div>
<div>
<Link href={'/root'}>
<a id="goto-home">home</a>
<Link href={'/root'} id="goto-home">
home
</Link>
</div>
</>
......
......@@ -3,8 +3,8 @@ export default function HomePage() {
return (
<>
<p>
<Link href="/a/">
<a id="to-a-trailing-slash">To a with trailing slash</a>
<Link href="/a/" id="to-a-trailing-slash">
To a with trailing slash
</Link>
</p>
</>
......
......@@ -13,11 +13,12 @@ export default function Page({ port }) {
const router = useRouter()
return (
<>
<Link href={`http://localhost:${port}${router.basePath}/something-else`}>
<a id="absolute-link">
http://localhost:{port}
{router.basePath}/something-else
</a>
<Link
href={`http://localhost:${port}${router.basePath}/something-else`}
id="absolute-link"
>
http://localhost:{port}
{router.basePath}/something-else
</Link>
</>
)
......
......@@ -11,8 +11,11 @@ export async function getServerSideProps({ query: { port } }) {
export default function Page({ port }) {
return (
<>
<Link href={`http://localhost:${port}/rewrite-no-basepath`}>
<a id="absolute-link">http://localhost:{port}/rewrite-no-basepath</a>
<Link
href={`http://localhost:${port}/rewrite-no-basepath`}
id="absolute-link"
>
http://localhost:{port}/rewrite-no-basepath
</Link>
</>
)
......
......@@ -4,12 +4,12 @@ import Link from 'next/link'
export default function Page() {
return (
<>
<Link href="https://vercel.com/">
<a id="absolute-link">https://vercel.com/</a>
<Link href="https://vercel.com/" id="absolute-link">
https://vercel.com/
</Link>
<br />
<Link href="mailto:idk@idk.com">
<a id="mailto-link">mailto:idk@idk.com</a>
<Link href="mailto:idk@idk.com" id="mailto-link">
mailto:idk@idk.com
</Link>
</>
)
......
......@@ -3,49 +3,39 @@ import { useRouter } from 'next/router'
const Page = () => (
<>
<Link href="/other-page">
<a id="other-page-link">
<h1>Hello World</h1>
</a>
<Link href="/other-page" id="other-page-link">
<h1>Hello World</h1>
</Link>
<br />
<Link href="/gsp">
<a id="gsp-link">
<h1>getStaticProps</h1>
</a>
<Link href="/gsp" id="gsp-link">
<h1>getStaticProps</h1>
</Link>
<br />
<Link href="/gssp">
<a id="gssp-link">
<h1>getServerSideProps</h1>
</a>
<Link href="/gssp" id="gssp-link">
<h1>getServerSideProps</h1>
</Link>
<br />
<Link href="/[slug]" as="/first">
<a id="dynamic-link">
<h1>dynamic page</h1>
</a>
<Link href="/[slug]" as="/first" id="dynamic-link">
<h1>dynamic page</h1>
</Link>
<br />
<Link href="/catchall/[...parts]" as="/catchall/hello/world">
<a id="catchall-link">
<h1>catchall page</h1>
</a>
<Link
href="/catchall/[...parts]"
as="/catchall/hello/world"
id="catchall-link"
>
<h1>catchall page</h1>
</Link>
<br />
<Link href="/">
<a id="index-gsp">
<h1>index getStaticProps</h1>
</a>
<Link href="/" id="index-gsp">
<h1>index getStaticProps</h1>
</Link>
<br />
<Link href="/index">
<a id="nested-index-gsp">
<h1>nested index getStaticProps</h1>
</a>
<Link href="/index" id="nested-index-gsp">
<h1>nested index getStaticProps</h1>
</Link>
<Link href="#hashlink">
<a id="hashlink">Hash Link</a>
<Link href="#hashlink" id="hashlink">
Hash Link
</Link>
<br />
<div id="base-path">{useRouter().basePath}</div>
......@@ -60,23 +50,17 @@ const Page = () => (
</div>
<br />
<div id="as-path">{useRouter().asPath}</div>
<Link href="/slow-route">
<a id="slow-route">
<h1>Slow route</h1>
</a>
<Link href="/slow-route" id="slow-route">
<h1>Slow route</h1>
</Link>
<Link href="/error-route">
<a id="error-route">
<h1>Error route</h1>
</a>
<Link href="/error-route" id="error-route">
<h1>Error route</h1>
</Link>
<Link href="/hello#some-hash">
<a id="hash-change">
<h1>Hash change</h1>
</a>
<Link href="/hello#some-hash" id="hash-change">
<h1>Hash change</h1>
</Link>
<Link href="/something-else" as="/hello">
<a id="something-else-link">to something else</a>
<Link href="/something-else" as="/hello" id="something-else-link">
to something else
</Link>
</>
)
......
......@@ -20,8 +20,8 @@ export default function Index({ hello, nested }) {
<p id="query">{JSON.stringify(query)}</p>
<p id="pathname">{pathname}</p>
<p id="as-path">{asPath}</p>
<Link href="/hello">
<a id="hello-link">to /hello</a>
<Link href="/hello" id="hello-link">
to /hello
</Link>
</>
)
......
......@@ -3,10 +3,8 @@ import { useRouter } from 'next/router'
const Page = () => (
<>
<Link href={`${useRouter().basePath}/other-page`}>
<a id="other-page-link">
<h1>Hello World</h1>
</a>
<Link href={`${useRouter().basePath}/other-page`} id="other-page-link">
<h1>Hello World</h1>
</Link>
</>
)
......
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Page() {
return (
<>
<Link href="/">
<a id="link-back">back</a>
<Link href="/" id="link-back">
back
</Link>
</>
)
......
......@@ -23,8 +23,8 @@ describe('Dynamic Route Interpolation', () => {
return (
<>
<p id="slug">{props.slug}</p>
<Link href={router.asPath}>
<a id="now">{props.now}</a>
<Link id="now" href={router.asPath}>
{props.now}
</Link>
</>
)
......
......@@ -19,12 +19,12 @@ export default ({ world, time }) => (
<>
<p>hello {world}</p>
<span id="anotherTime">time: {time}</span>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/something">
<a id="something">to something</a>
<Link href="/something" id="something">
to something
</Link>
</>
)
......@@ -17,8 +17,8 @@ export default ({ post, comment, time }) => {
<p>Post: {post}</p>
<p>Comment: {comment}</p>
<span>time: {time}</span>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
</>
)
......
......@@ -36,8 +36,8 @@ export default ({ post, time, params, appProps, resolvedUrl }) => {
<div id="app-url">{appProps.url}</div>
<div id="resolved-url">{resolvedUrl}</div>
<div id="as-path">{router.asPath}</div>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
</>
)
......
......@@ -15,8 +15,8 @@ export default ({ slugs, time }) => {
<>
<p>Posts: {JSON.stringify(slugs)}</p>
<span>time: {time}</span>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
</>
)
......
......@@ -21,12 +21,12 @@ export default ({ world, time, params, random }) => {
<div id="random">{random}</div>
<div id="params">{JSON.stringify(params)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/another">
<a id="another">to another</a>
<Link href="/another" id="another">
to another
</Link>
</>
)
......
......@@ -13,12 +13,12 @@ export default ({ world, time }) => (
<>
<p>hello {world}</p>
<span>time: {time}</span>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/something">
<a id="something">to something</a>
<Link href="/something" id="something">
to something
</Link>
</>
)
......@@ -56,38 +56,42 @@ const Page = ({ world, time, url }) => {
<>
<p>hello {world}</p>
<span>time: {time}</span>
<Link href="/non-json">
<a id="non-json">to non-json</a>
<Link href="/non-json" id="non-json">
to non-json
</Link>
<br />
<Link href="/another">
<a id="another">to another</a>
<Link href="/another" id="another">
to another
</Link>
<br />
<Link href="/something">
<a id="something">to something</a>
<Link href="/something" id="something">
to something
</Link>
<br />
<Link href="/normal">
<a id="normal">to normal</a>
<Link href="/normal" id="normal">
to normal
</Link>
<br />
<Link href="/slow">
<a id="slow">to slow</a>
<Link href="/slow" id="slow">
to slow
</Link>
<br />
<Link href="/blog/[post]" as="/blog/post-1">
<a id="post-1">to dynamic</a>
<Link href="/blog/[post]" as="/blog/post-1" id="post-1">
to dynamic
</Link>
<Link href="/blog/[post]" as="/blog/post-100">
<a id="broken-post">to broken</a>
<Link href="/blog/[post]" as="/blog/post-100" id="broken-post">
to broken
</Link>
<br />
<Link href="/blog/[post]/[comment]" as="/blog/post-1/comment-1">
<a id="comment-1">to another dynamic</a>
<Link
href="/blog/[post]/[comment]"
as="/blog/post-1/comment-1"
id="comment-1"
>
to another dynamic
</Link>
<Link href="/something?another=thing">
<a id="something-query">to something?another=thing</a>
<Link href="/something?another=thing" id="something-query">
to something?another=thing
</Link>
</>
)
......
......@@ -21,12 +21,12 @@ export default ({ world, time, params, random, query }) => {
<div id="params">{JSON.stringify(params)}</div>
<div id="initial-query">{JSON.stringify(query)}</div>
<div id="query">{JSON.stringify(useRouter().query)}</div>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/another">
<a id="another">to another</a>
<Link href="/another" id="another">
to another
</Link>
</>
)
......
......@@ -11,8 +11,8 @@ export default function Page(props) {
<p id="router-query">{JSON.stringify(router.query)}</p>
<p id="router-pathname">{router.pathname}</p>
<p id="router-as-path">{router.asPath}</p>
<Link href="/">
<a id="to-index">to /</a>
<Link href="/" id="to-index">
to /
</Link>
<br />
</>
......
......@@ -11,8 +11,8 @@ export default function Page(props) {
<p id="router-query">{JSON.stringify(router.query)}</p>
<p id="router-pathname">{router.pathname}</p>
<p id="router-as-path">{router.asPath}</p>
<Link href="/">
<a id="to-index">to /</a>
<Link href="/" id="to-index">
to /
</Link>
<br />
</>
......
......@@ -15,12 +15,12 @@ export default ({ count }) => (
<>
<p>a slow page</p>
<p id="hit">hit: {count}</p>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/something">
<a id="something">to something</a>
<Link href="/something" id="something">
to something
</Link>
</>
)
......@@ -38,12 +38,12 @@ export default ({
<div id="app-url">{appProps.url}</div>
<div id="resolved-url">{resolvedUrl}</div>
<div id="as-path">{router.asPath}</div>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
<br />
<Link href="/another">
<a id="another">to another</a>
<Link href="/another" id="another">
to another
</Link>
</>
)
......
......@@ -15,8 +15,8 @@ export default ({ user, time }) => {
<>
<p>User: {user}</p>
<span>time: {time}</span>
<Link href="/">
<a id="home">to home</a>
<Link href="/" id="home">
to home
</Link>
</>
)
......
......@@ -3,38 +3,40 @@ import Link from 'next/link'
export default function Component() {
return (
<>
<Link href="/gssp-redirect/en">
<a id="to-gssp-redirect-en">to /gssp-redirect/en"</a>
<Link href="/gssp-redirect/en" id="to-gssp-redirect-en">
to /gssp-redirect/en"
</Link>
<Link href="/gssp-redirect/sv">
<a id="to-gssp-redirect-sv">to /gssp-redirect/sv"</a>
<Link href="/gssp-redirect/sv" id="to-gssp-redirect-sv">
to /gssp-redirect/sv"
</Link>
<Link href="/gssp-redirect/from-ctx">
<a id="to-gssp-redirect-from-ctx">to /gssp-redirect/from-ctx</a>
<Link href="/gssp-redirect/from-ctx" id="to-gssp-redirect-from-ctx">
to /gssp-redirect/from-ctx
</Link>
<Link href="/gsp-blocking-redirect/en">
<a id="to-gsp-blocking-redirect-en">to /gsp-blocking-redirect/en"</a>
<Link href="/gsp-blocking-redirect/en" id="to-gsp-blocking-redirect-en">
to /gsp-blocking-redirect/en"
</Link>
<Link href="/gsp-blocking-redirect/sv">
<a id="to-gsp-blocking-redirect-sv">to /gsp-blocking-redirect/sv"</a>
<Link href="/gsp-blocking-redirect/sv" id="to-gsp-blocking-redirect-sv">
to /gsp-blocking-redirect/sv"
</Link>
<Link href="/gsp-blocking-redirect/from-ctx">
<a id="to-gsp-blocking-redirect-from-ctx">
to /gsp-blocking-redirect/from-ctx
</a>
<Link
href="/gsp-blocking-redirect/from-ctx"
id="to-gsp-blocking-redirect-from-ctx"
>
to /gsp-blocking-redirect/from-ctx
</Link>
<Link href="/gsp-fallback-redirect/en">
<a id="to-gsp-fallback-redirect-en">to /gsp-fallback-redirect/en"</a>
<Link href="/gsp-fallback-redirect/en" id="to-gsp-fallback-redirect-en">
to /gsp-fallback-redirect/en"
</Link>
<Link href="/gsp-fallback-redirect/sv">
<a id="to-gsp-fallback-redirect-sv">to /gsp-fallback-redirect/sv"</a>
<Link href="/gsp-fallback-redirect/sv" id="to-gsp-fallback-redirect-sv">
to /gsp-fallback-redirect/sv"
</Link>
<Link href="/gsp-fallback-redirect/from-ctx">
<a id="to-gsp-fallback-redirect-from-ctx">
to /gsp-fallback-redirect/from-ctx
</a>
<Link
href="/gsp-fallback-redirect/from-ctx"
id="to-gsp-fallback-redirect-from-ctx"
>
to /gsp-fallback-redirect/from-ctx
</Link>
</>
)
......
......@@ -3,11 +3,11 @@ import Link from 'next/link'
export default function Page() {
return (
<div>
<Link href="/some/route/for?json=true">
<a id="rewrite">to /some/route/for?json=true</a>
<Link href="/some/route/for?json=true" id="rewrite">
to /some/route/for?json=true
</Link>
<Link href="/api/json">
<a id="direct">to /api/json</a>
<Link href="/api/json" id="direct">
to /api/json
</Link>
</div>
)
......
......@@ -27,13 +27,13 @@ export default function Page(props) {
)}
</p>
<Link href="/">
<a id="to-index">to /index</a>
<Link href="/" id="to-index">
to /index
</Link>
<br />
<Link href="/dynamic/first">
<a id="to-dynamic">to /dynamic/first</a>
<Link href="/dynamic/first" id="to-dynamic">
to /dynamic/first
</Link>
<br />
</>
......
......@@ -27,13 +27,13 @@ export default function Page(props) {
)}
</p>
<Link href="/">
<a id="to-index">to /index</a>
<Link href="/" id="to-index">
to /index
</Link>
<br />
<Link href="/dynamic/second">
<a id="to-dynamic">to /dynamic/second</a>
<Link href="/dynamic/second" id="to-dynamic">
to /dynamic/second
</Link>
<br />
</>
......
......@@ -27,13 +27,13 @@ export default function Page(props) {
)}
</p>
<Link href="/another">
<a id="to-another">to /another</a>
<Link href="/another" id="to-another">
to /another
</Link>
<br />
<Link href="/dynamic/first">
<a id="to-dynamic">to /dynamic/first</a>
<Link href="/dynamic/first" id="to-dynamic">
to /dynamic/first
</Link>
<br />
</>
......
......@@ -6,30 +6,29 @@ export default function Main({ message }) {
<h1 className="title">Hello {message}</h1>
<ul>
<li>
<Link href="/stream-response">
<a>Stream a response</a>
</Link>
<Link href="/stream-response">Stream a response</Link>
</li>
<li>
<Link href="/rewrite-me-to-about?message=refreshed">
<a id="link-with-rewritten-url" className={message}>
Rewrite me to about
</a>
<Link
href="/rewrite-me-to-about?message=refreshed"
id="link-with-rewritten-url"
className={message}
>
Rewrite me to about
</Link>
</li>
<li>
<Link href="/rewrite-me-to-vercel">
<a>Rewrite me to Vercel</a>
</Link>
<Link href="/rewrite-me-to-vercel">Rewrite me to Vercel</Link>
</li>
<li>
<Link href="/redirect-me-to-about">
<a>redirect me to about</a>
</Link>
<Link href="/redirect-me-to-about">redirect me to about</Link>
</li>
<li>
<Link href="/dynamic-routes/hello-world">
<a id="go-to-hello-world-anchor">Hello World</a>
<Link
href="/dynamic-routes/hello-world"
id="go-to-hello-world-anchor"
>
Hello World
</Link>
</li>
</ul>
......
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default (props) => (
<ul>
<li>
<Link href="/hello">
<a id="hello">/hello</a>
<Link href="/hello" id="hello">
/hello
</Link>
</li>
</ul>
......
......@@ -3,23 +3,23 @@ import Link from 'next/link'
export default (props) => (
<ul>
<li>
<Link href="/hello">
<a id="hello">/hello</a>
<Link href="/hello" id="hello">
/hello
</Link>
</li>
<li>
<Link href="/en/hello">
<a id="en_hello">/en/hello</a>
<Link href="/en/hello" id="en_hello">
/en/hello
</Link>
</li>
<li>
<Link href="/nl-NL/hello">
<a id="nl-NL_hello">/nl-NL/hello</a>
<Link href="/nl-NL/hello" id="nl-NL_hello">
/nl-NL/hello
</Link>
</li>
<li>
<Link href="/nl-NL/about">
<a id="nl-NL_about">/nl-NL/about</a>
<Link href="/nl-NL/about" id="nl-NL_about">
/nl-NL/about
</Link>
</li>
</ul>
......
......@@ -3,13 +3,13 @@ import Link from 'next/link'
export default (props) => (
<ul>
<li>
<Link href="/has-match-2?my-query=hellooo">
<a id="has-match-2">has-match-2</a>
<Link href="/has-match-2?my-query=hellooo" id="has-match-2">
has-match-2
</Link>
</li>
<li>
<Link href="/has-match-3">
<a id="has-match-3">has-match-3</a>
<Link href="/has-match-3" id="has-match-3">
has-match-3
</Link>
</li>
</ul>
......
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Errors() {
return (
<div>
<Link href="/error-throw?message=refreshed">
<a id="throw-on-data">Throw on data</a>
<Link href="/error-throw?message=refreshed" id="throw-on-data">
Throw on data
</Link>
</div>
)
......
......@@ -8,13 +8,13 @@ export default function Shallow({ message }) {
<ul>
<li id="message-contents">{message}</li>
<li>
<Link href="/sha?hello=world" shallow>
<a id="shallow-link">Shallow link to ?hello=world</a>
<Link href="/sha?hello=world" shallow id="shallow-link">
Shallow link to ?hello=world
</Link>
</li>
<li>
<Link href="/sha?hello=goodbye">
<a id="deep-link">Deep link to ?hello=goodbye</a>
<Link href="/sha?hello=goodbye" id="deep-link">
Deep link to ?hello=goodbye
</Link>
</li>
<li>
......
......@@ -5,8 +5,8 @@ export default function Page(props) {
<div>
<p id="another-middleware">This should also run the middleware</p>
<p id="props">{JSON.stringify(props)}</p>
<Link href="/">
<a id="to-index">to /</a>
<Link href="/" id="to-index">
to /
</Link>
<br />
</div>
......
......@@ -5,12 +5,12 @@ export default function Page(props) {
<div>
<p id="blog">This should not run the middleware</p>
<p id="props">{JSON.stringify(props)}</p>
<Link href="/another-middleware">
<a id="to-another-middleware">to /another-middleware</a>
<Link href="/another-middleware" id="to-another-middleware">
to /another-middleware
</Link>
<br />
<Link href="/blog/slug-2">
<a id="to-blog-slug-2">to /blog/slug-2</a>
<Link href="/blog/slug-2" id="to-blog-slug-2">
to /blog/slug-2
</Link>
<br />
</div>
......
......@@ -5,12 +5,12 @@ export default function Page(props) {
<div>
<p id="index">root page</p>
<p id="props">{JSON.stringify(props)}</p>
<Link href="/another-middleware">
<a id="to-another-middleware">to /another-middleware</a>
<Link href="/another-middleware" id="to-another-middleware">
to /another-middleware
</Link>
<br />
<Link href="/blog/slug-1">
<a id="to-blog-slug-1">to /blog/slug-1</a>
<Link href="/blog/slug-1" id="to-blog-slug-1">
to /blog/slug-1
</Link>
<br />
</div>
......
......@@ -4,42 +4,38 @@ export default function Home() {
return (
<div>
<p className="title">Home Page</p>
<Link href="/old-home">
<a id="old-home">Redirect me to a new version of a page</a>
<Link href="/old-home" id="old-home">
Redirect me to a new version of a page
</Link>
<div />
<Link href="/old-home?override=external">
<a id="old-home-external">Redirect me to an external site</a>
<Link href="/old-home?override=external" id="old-home-external">
Redirect me to an external site
</Link>
<div />
<Link href="/blank-page?foo=bar">
<a>Redirect me with URL params intact</a>
</Link>
<Link href="/blank-page?foo=bar">Redirect me with URL params intact</Link>
<div />
<Link href="/redirect-to-google">
<a>Redirect me to Google (with no body response)</a>
Redirect me to Google (with no body response)
</Link>
<div />
<Link href="/redirect-to-google">
<a>Redirect me to Google (with no stream response)</a>
Redirect me to Google (with no stream response)
</Link>
<div />
<Link href="/redirect-me-alot">
<a>Redirect me alot (chained requests)</a>
</Link>
<Link href="/redirect-me-alot">Redirect me alot (chained requests)</Link>
<div />
<Link href="/infinite-loop">
<a>Redirect me alot (infinite loop)</a>
</Link>
<Link href="/infinite-loop">Redirect me alot (infinite loop)</Link>
<div />
<Link href="/to?pathname=/api/ok" locale="nl">
<a id="link-to-api-with-locale">Redirect me to api with locale</a>
<Link
href="/to?pathname=/api/ok"
locale="nl"
id="link-to-api-with-locale"
>
Redirect me to api with locale
</Link>
<div />
<Link href="/to?pathname=/old-home">
<a id="link-to-to-old-home">
Redirect me to a redirecting page of new version of page
</a>
<Link href="/to?pathname=/old-home" id="link-to-to-old-home">
Redirect me to a redirecting page of new version of page
</Link>
<div />
</div>
......
......@@ -4,60 +4,40 @@ export default function Home({ message }) {
return (
<div>
<p className="title">Hello {message}</p>
<Link href="/stream-a-response">
<a>Stream a response</a>
</Link>
<Link href="/stream-a-response">Stream a response</Link>
<div />
<Link href="/stream-long">
<a>Stream a long response</a>
</Link>
<Link href="/stream-end-stream">
<a>Test streaming after response ends</a>
</Link>
<Link href="/stream-long">Stream a long response</Link>
<Link href="/stream-end-stream">Test streaming after response ends</Link>
<div />
<Link href="/stream-header-end">
<a>Attempt to add a header after stream ends</a>
Attempt to add a header after stream ends
</Link>
<div />
<Link href="/redirect-stream">
<a>Redirect to Google and attempt to stream after</a>
Redirect to Google and attempt to stream after
</Link>
<div />
<Link href="/header">
<a>Respond with a header</a>
</Link>
<Link href="/header">Respond with a header</Link>
<div />
<Link href="/header?nested-header=true">
<a>Respond with 2 headers (nested middleware effect)</a>
Respond with 2 headers (nested middleware effect)
</Link>
<div />
<Link href="/body-end-header">
<a>Respond with body, end, set a header</a>
</Link>
<Link href="/body-end-header">Respond with body, end, set a header</Link>
<div />
<Link href="/body-end-body">
<a>Respond with body, end, send another body</a>
Respond with body, end, send another body
</Link>
<div />
<Link href="/send-response">
<a>Respond with body</a>
</Link>
<Link href="/send-response">Respond with body</Link>
<div />
<Link href="/redirect-body">
<a>Redirect and then send a body</a>
</Link>
<Link href="/redirect-body">Redirect and then send a body</Link>
<div />
<Link href="/react">
<a>Send React component as a body</a>
</Link>
<Link href="/react">Send React component as a body</Link>
<div />
<Link href="/react-stream">
<a>Stream React component</a>
</Link>
<Link href="/react-stream">Stream React component</Link>
<div />
<Link href="/bad-status">
<a>404</a>
</Link>
<Link href="/bad-status">404</Link>
<div />
</div>
)
......
......@@ -9,12 +9,16 @@ export default function Page(props) {
return (
<>
<p id="props">{JSON.stringify(props)}</p>
<Link href="/fallback-true-blog/first?hello=world" shallow>
<a id="to-query-shallow">to /fallback-true-blog/first?hello=world</a>
<Link
href="/fallback-true-blog/first?hello=world"
shallow
id="to-query-shallow"
>
to /fallback-true-blog/first?hello=world
</Link>
<br />
<Link href="/fallback-true-blog/second" shallow>
<a id="to-no-query-shallow">to /fallback-true-blog/second</a>
<Link href="/fallback-true-blog/second" shallow id="to-no-query-shallow">
to /fallback-true-blog/second
</Link>
<br />
</>
......
......@@ -6,28 +6,28 @@ export default function Home({ locale }) {
<div className={locale}>{locale}</div>
<ul>
<li>
<Link href="/i18n" locale="en">
<a id="link-en">Go to en</a>
<Link href="/i18n" locale="en" id="link-en">
Go to en
</Link>
</li>
<li>
<Link href="/en/i18n" locale={false}>
<a id="link-en2">Go to en2</a>
<Link href="/en/i18n" locale={false} id="link-en2">
Go to en2
</Link>
</li>
<li>
<Link href="/i18n" locale="ja">
<a id="link-ja">Go to ja</a>
<Link href="/i18n" locale="ja" id="link-ja">
Go to ja
</Link>
</li>
<li>
<Link href="/ja/i18n" locale={false}>
<a id="link-ja2">Go to ja2</a>
<Link href="/ja/i18n" locale={false} id="link-ja2">
Go to ja2
</Link>
</li>
<li>
<Link href="/i18n" locale="fr">
<a id="link-fr">Go to fr</a>
<Link href="/i18n" locale="fr" id="link-fr">
Go to fr
</Link>
</li>
</ul>
......
......@@ -7,48 +7,52 @@ export default function Home() {
<div>
<p className="title">Home Page</p>
<div />
<Link href="/rewrite-to-ab-test">
<a>A/B test homepage</a>
</Link>
<Link href="/rewrite-to-ab-test">A/B test homepage</Link>
<div />
<Link href="/rewrite-me-to-about?override=internal">
<a id="rewrite-me-to-about">Rewrite me to about</a>
<Link
href="/rewrite-me-to-about?override=internal"
id="rewrite-me-to-about"
>
Rewrite me to about
</Link>
<div />
<Link href="/rewrite-to-beforefiles-rewrite">
<a id="rewrite-to-beforefiles-rewrite">
Rewrite me to beforeFiles Rewrite
</a>
<Link
href="/rewrite-to-beforefiles-rewrite"
id="rewrite-to-beforefiles-rewrite"
>
Rewrite me to beforeFiles Rewrite
</Link>
<div />
<Link href="/rewrite-to-afterfiles-rewrite">
<a id="rewrite-to-afterfiles-rewrite">
Rewrite me to afterFiles Rewrite
</a>
<Link
href="/rewrite-to-afterfiles-rewrite"
id="rewrite-to-afterfiles-rewrite"
>
Rewrite me to afterFiles Rewrite
</Link>
<div />
<Link href="/rewrite-me-to-vercel">
<a>Rewrite me to Vercel</a>
</Link>
<Link href="/rewrite-me-to-vercel">Rewrite me to Vercel</Link>
<div />
<Link href="/rewrite-me-external-twice">
<a>Redirect me to Vercel (but with double reroutes)</a>
Redirect me to Vercel (but with double reroutes)
</Link>
<div />
<Link href="/rewrite-me-without-hard-navigation?message=refreshed">
<a id="link-with-rewritten-url">Rewrite me without a hard navigation</a>
<Link
href="/rewrite-me-without-hard-navigation?message=refreshed"
id="link-with-rewritten-url"
>
Rewrite me without a hard navigation
</Link>
<div />
<Link href="/about?override=external">
<a id="override-with-external-rewrite">Rewrite me to external site</a>
<Link href="/about?override=external" id="override-with-external-rewrite">
Rewrite me to external site
</Link>
<div />
<Link href="/about?override=internal">
<a id="override-with-internal-rewrite">Rewrite me to internal path</a>
<Link href="/about?override=internal" id="override-with-internal-rewrite">
Rewrite me to internal path
</Link>
<div />
<Link href="/ssg">
<a id="normal-ssg-link">normal SSG link</a>
<Link href="/ssg" id="normal-ssg-link">
normal SSG link
</Link>
<div />
<a
......
......@@ -3,8 +3,8 @@ import Link from 'next/link'
export default function Errors() {
return (
<div>
<Link href="/error-throw?message=refreshed">
<a id="throw-on-data">Throw on data</a>
<Link href="/error-throw?message=refreshed" id="throw-on-data">
Throw on data
</Link>
</div>
)
......
......@@ -8,13 +8,13 @@ export default function Shallow({ message }) {
<ul>
<li id="message-contents">{message}</li>
<li>
<Link href="/sha?hello=world" shallow>
<a id="shallow-link">Shallow link to ?hello=world</a>
<Link href="/sha?hello=world" shallow id="shallow-link">
Shallow link to ?hello=world
</Link>
</li>
<li>
<Link href="/sha?hello=goodbye">
<a id="deep-link">Deep link to ?hello=goodbye</a>
<Link href="/sha?hello=goodbye" id="deep-link">
Deep link to ?hello=goodbye
</Link>
</li>
<li>
......
module.exports = {
experimental: {
newNextLinkBehavior: true,
},
}
module.exports = {}
module.exports = {
reactStrictMode: true,
experimental: {
newNextLinkBehavior: true,
},
}
module.exports = {
reactStrictMode: true,
experimental: {
newNextLinkBehavior: true,
},
}
module.exports = {
reactStrictMode: true,
experimental: {
newNextLinkBehavior: true,
},
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment