Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic routes clarification #8110

Merged
merged 5 commits into from
Jul 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,20 @@ A `<Link>` for `/post/abc` looks like so:
</Link>
```

- `href`: the path inside `pages` directory
- `as`: the path that will be rendered in the browser URL bar
- `href`: the path inside `pages` directory.
- `as`: the path that will be rendered in the browser URL bar.

As `href` is a filesystem path, it shouldn't change at runtime, instead, you will probably need to change `as`
dynamically according to your needs. Here's an example to create a list of links:

```jsx
const pids = ['id1', 'id2', 'id3'];
{pids.map(pid => (
<Link href="/post/[pid]" as={`/post/${pid}`}>
<a>Post {pid}</a>
</Link>
))}
```

> You can [read more about `<Link>` here](#with-link).

Expand Down