naopoyo.com
  • Docs
  • Tags
  • Bookmarks
  • Tools
  • About
  • Docs
  • Tags
  • Bookmarks
  • Tools
  • About

目次

© naopoyo

🛍️

Next.js Commerceのソースコードを読みながら調べたことをメモする

公開日
約2年前
2023-10-20
更新日
約2年前
2023-10-21
更新履歴
GitHubで見る
  • Next.js
preview

Next.js Commerce のソースコード

GitHub - vercel/commerce: Next.js Commerce
Next.js Commerce. Contribute to vercel/commerce development by creating an account on GitHub.
github.com favicon
github.com
GitHub - vercel/commerce: Next.js Commerce

上記のコードを読みながらNext.jsのApp Routerでのお作法などを学んでいく。

デモサイト: https://demo.vercel.store/

Edge Runtime

export const runtime = 'edge'

page.tsx などで大体このように書かれている。edge だと高速になるらしい。

このサイトで試したらビルドエラーになってしまった。Edge Runtimeは高速にするために、色々と制限があるらしい。

参考: Rendering: Edge and Node.js Runtimes | Next.js

metadata

Metadataの細かいところを見ていく。

参考: Optimizing: Metadata | Next.js

metadataのtitle

title: {
  default: SITE_NAME!,
  template: `%s | ${SITE_NAME}`
}

title の template を指定することで、「about | SITE_NAME」のようなtitleにできる。

metadataのrobots

robots: {
  follow: true,
  index: true
},

metaタグのrobotsを設定できる。例)<meta name="robots" content="index, follow"/>

参考: meta robotsとは?robots.txtの役割と使い方

sitemap.xml

app/sitemap.ts を作成することで https://example.com/sitemap.xml が出力される。

参考:

  • Metadata Files: sitemap.xml | Next.js
  • commerce/app/sitemap.ts at main · vercel/commerce

robots.txt

sitemap.xmlと同じく app/robots.ts を作成することで https://example.com/robots.txt が出力される。

参考:

  • Metadata Files: robots.txt | Next.js
  • commerce/app/robots.ts at main · vercel/commerce

package.jsonを見てみる

  • @headlessui/react
    Headless UI - Unstyled, fully accessible UI components
  • @heroicons/react
    Heroicons
  • clsx
    lukeed/clsx: A tiny (228B) utility for constructing `className` strings conditionally.
    クラス名の加工を行うユーティリティ。
  • eslint-plugin-unicorn
    sindresorhus/eslint-plugin-unicorn: More than 100 powerful ESLint rules
    ESLintのルールがいっぱいセットになっている。
  • lint-staged
    lint-staged/lint-staged: 🚫💩 — Run linters on git staged files
    コミット前にLintするためのパッケージ。
  • @vercel/git-hooks
    vercel/git-hooks: No nonsense Git hook management
    Gitのhookの管理を簡単にする。

目次

最近更新された記事

🎮
ゲーム開発日記4
14日前 - 2025年11月03日
  • Unity
  • ゲーム開発
🐩
開発日記-2025-11-02 / git worktree について調べる
15日前 - 2025年11月02日
  • 開発日記
🌇
開発日記-2025-10-31 / Xのブックマークに入れてたサイトを読む
18日前 - 2025年10月31日
  • 開発日記