일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
- Ethereum
- SSR
- CLASS
- blockchain
- Redux
- CSS
- tailwindcss
- hardhat
- JavaScript
- error
- typeScript
- concept
- HTML
- node.js
- bitcoin
- express.js
- built in object
- REACT
- web
- 기준
- Interface
- Props
- solidity
- useState
- nextJS
- evm
- graphQL
- middleware
- API
- 삶
- Today
- Total
ReasonJun
Next.js : <Link> vs <a> (Client-side navigation) 본문
The <Link> and <a> components in Next.js are both used to create hyperlinks, but they have some key differences.
The <Link> component is a React component that extends the HTML <a> element. It provides a number of features that are not available in the <a> element, such as:
- Client-side navigation: The <Link> component can be used to perform client-side navigation, which means that the page will not be reloaded when the link is clicked. This can improve the performance of your application.
- Prefetching: The <Link> component can be used to prefetch the next page, which means that the page will be loaded in the background before the user clicks the link. This can improve the user experience by reducing the perceived loading time. In other words, if <Link> component is used, when Link component is exposed in Viewport, chunk of page connected by href is loaded.
- SEO: The <Link> component is SEO-friendly, which means that search engines will be able to index the links on your pages. This can help your pages to rank higher in search engine results pages (SERPs).
The <a> element is a standard HTML element that does not provide any of the features of the <Link> component. However, the <a> element can be used to create links that work in all browsers, including browsers that do not support Next.js.
In general, you should use the <Link> component whenever possible. However, if you need to create a link that works in all browsers, then you can use the <a> element.
Here is a table that summarizes the key differences between the <Link> and <a> components:
Feature | <Link> | <a> |
Client-side navigation | Yes | No |
Prefetching | Yes | No |
SEO-friendly | Yes | No |
Works in all browsers | No | Yes |
Client-side navigation
Unlike moving by directly hitting the url in the browser, replacing the page component on JS. Only the JS parts that need to be changed are reloaded. Not all reloaded.
🚨 Precautions when using
When connecting to an external link from this service, only <a> is required.
When giving a style to a link component, it must be given to an internal tag.
'Frontend > Next.js' 카테고리의 다른 글
Next.js : Compiler SWC (Speedy Web Compiler) (0) | 2023.06.20 |
---|---|
When is it good to use SSG in next.js? (0) | 2023.06.19 |
Next.js : API Routes (0) | 2023.06.18 |
Next.js : File System-based Routing (Shallow Routing) (0) | 2023.06.18 |
Next.js : File System-based Routing (Dynamic Routing ) (0) | 2023.06.18 |