コンテンツへスキップ

onDemandEntries

Next.js は、開発環境でサーバーがビルドされたページをメモリに保持または破棄する方法を制御するためのいくつかのオプションを提供しています。

デフォルトを変更するには、next.config.js を開き、onDemandEntries 設定を追加します。

next.config.js
module.exports = {
  onDemandEntries: {
    // period (in ms) where the server will keep pages in the buffer
    maxInactiveAge: 25 * 1000,
    // number of pages that should be kept simultaneously without being disposed
    pagesBufferLength: 2,
  },
}