1
1

More than 1 year has passed since last update.

Next.jsでpages配下のurlに紐づくファイルをindex.page.tsxにする方法

Last updated at Posted at 2022-09-11

アプリが大規模になってくると、ファイルがかなり多くなってくるので、urlにひもづくファイルを一目で見分けたいときなんかに使える。

実装方法

とはいってもやることは簡単。

next.config.js
/** @type {import('next').NextConfig} */
module.exports = {
  swcMinify: true,
  reactStrictMode: true,
  //pageExtensionsを追加
  pageExtensions: ['page.tsx', 'page.ts'],
};

あとは

_app.tsx → _app.page.tsx
index.tsx → indexs.page.tsx

などするだけ。

簡単な修正のだが、割と便利だと思う。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1