Skip to content

Commit 12e8b12

Browse files
timneutkensarunoda
authored andcommitted
Document usage of <Link> without <a> (vercel#2369)
1 parent 3d162d9 commit 12e8b12

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

readme.md

+14
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,8 @@ export default () => (
319319

320320
That will generate the URL string `/about?name=Zeit`, you can use every property as defined in the [Node.js URL module documentation](https://nodejs.org/api/url.html#url_url_strings_and_url_objects).
321321

322+
##### Replace instead of push url
323+
322324
The default behaviour for the `<Link>` component is to `push` a new url into the stack. You can use the `replace` prop to prevent adding a new entry.
323325

324326
```jsx
@@ -329,6 +331,18 @@ export default () => (
329331
)
330332
```
331333

334+
##### Using a component that support `onClick`
335+
336+
`<Link>` supports any component that supports the `onClick` event. In case you don't provide an `<a>` tag, it will only add the `onClick` event handler and won't pass the `href` property.
337+
338+
```jsx
339+
// pages/index.js
340+
import Link from 'next/link'
341+
export default () => (
342+
<div>Click <Link href='/about'><img src="/static/image.png"></Link></div>
343+
)
344+
```
345+
332346
#### Imperatively
333347

334348
<p><details>

0 commit comments

Comments
 (0)