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 app routerのGlobal Errorハンドリング

Posted at

概要

next.js公式docsapp/global-error.tsxはグローバルエラーBoundaryと書かれているが、実際には効かなかったため、メモする。

appルータの予期せぬエラー処理

  • error.tsx
    • appフォルダのサブフォルダにはerror.tsxを利用
  • global-error.tsx
    • appフォルダのサブフォルダにはglobal-error.tsxを利用
    • ルートエラーBoundaryとして特別扱い

実際は

  • 自分が使っているnext.js v15.1.4global-error.tsxが効かなかった
  • 代わりにerror.tsxが効く

つまり、global-error.tsxの特別扱いがなくなったっぽい。

感想

ルートの特別扱いをやめて、すべてerror.tsxに統一することで、より混乱が少なくて良かったと思う。

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?