0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

[Next.js] Next.jsなのにSSRができない!?静的ページが表示される場合の簡単な解決策

Last updated at Posted at 2025-02-07

Next.jsを使っている際、練習環境では動的にページを生成できたのに本番環境でSSRができず、静的ページが表示される問題に遭遇した。

調べたところ、Next.jsでは特に明示しなければビルド時に静的ページが表示されるようにできていることがわかった。

参考 : キャッシュで理解するNext.js App Routerのデータ取得

解決策は公式ドキュメントにあった。以下の1行を追加すればいいとのことである。

export const dynamic = 'force-dynamic'

Next.jsといえばSSRというイメージを持っている人もいると思うが、この1行がないと動的にページが生成されないので気をつけよう。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?