Open5

Next.jsチュートリアルをやってみる

AyuuAyuu

とりあえず3章まで.
今のところはそこまでややこしくはない印象〜
ただ,フォント指定とかスタイルとかclassName駆動だったのでプロジェクトが大きくなるとコード読みづらそうだな〜とか思った.
(これは他にやり方があったりサードパーティーでいいのがあるのかもしれない

AyuuAyuu

One benefit of using layouts in Next.js is that on navigation, only the page components update while the layout won't re-render. This is called partial rendering:

https://nextjs.org/learn/dashboard-app/creating-layouts-and-pages

部分レンダリングで変更のあったコンポーネントだけを再レンダリングしてくれるらしい.(reactでもできるけどよしなにやってくれるってことなのかな

AyuuAyuu

aタグを使って画面遷移するとページ全体が更新されてしまうのを問題視しているみたい.
<Link />コンポーネントを使うとJavaScriptでクライアントナビゲーションできるらしい.

AyuuAyuu

<Link />コンポーネント使うとSSRなのにSPAみたいにスムーズに画面遷移できる
すげぇ〜〜

Furthermore, in production, whenever <Link> components appear in the browser's viewport, Next.js automatically prefetches the code for the linked route in the background. By the time the user clicks the link, the code for the destination page will already be loaded in the background, and this is what makes the page transition near-instant!

本番環境だと<Link />が呼ばれるときに遷移先のコードをprefetchしているらしい.だからSPAチックに画面遷移ができるそう.
裏で先にURL踏んで開いておくイメージでいる