Next.js - Getting Started
https://nextjs.org/docs/app/getting-started
Installation
npx create-next-app@latest
Project Structure
特別な意味を持つファイル名
layout
- 複数のページで共有される UI
- 状態を維持しリセットされない
page
- 特定のラウトで表示される UI
loading
Loading UInot-found
Not Found UIerror
Error UIglobal-error
Global Error UIroute
API Endpointtemplate
- Re-rendered layout
- Layout とほぼ同じだが、ページが切り替わると状態が都度リセットされる点が異なる
default
Parallel route fallback page?
Nested Routes の表現
folder
Route Segmentfolder/folder
Nested Route Segment
Dynamic Routes の表現
[folder]
Dynamic Route Segment[...folder]
- Catch-all Route Segment
- e.g.
app/shop/[...slug]/page.js
だと以下にマッチする/shop/clothes
/shop/clothes/tops
/shop/clothes/tops/t-shirts
[[...folder]]
Optional Catch-all Route Segment- e.g.
app/shop/[[...slug]]/page.js
だと以下にマッチする/shop
(ここだけ違う)/shop/clothes
/shop/clothes/tops
/shop/clothes/tops/t-shirts
- e.g.