Add styled prerendered 404 page#43
Merged
Merged
Conversation
GitHub Pages serves a root-level 404.html for unknown URLs. Add a self-contained NotFound component, prerender it via a /404 route, and copy the output to build/client/404.html in the deploy workflow. The root ErrorBoundary also renders NotFound on a 404 — that's the path that runs when Pages serves 404.html at an unknown URL and the app boots with no matching route. Harden the Layout language check for the empty-match case since it's now on that path. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Serves a styled 404 for unknown URLs on GitHub Pages, instead of the default Pages error page.
How it works
NotFoundcomponent (large Fraunces "404", short EN + DE message, "Back home" button), theme-aware for light/dark.404route prerenders it to static HTML. The deploy workflow copiesbuild/client/404/index.html→build/client/404.html, the root-level file Pages serves for unknown URLs.ErrorBoundaryalso rendersNotFoundon a 404 — this is the path that actually runs when Pages serves404.htmlat an unknown URL and the app boots with no matching route. TheLayoutlanguage check is hardened for the empty-match case since it's now on that path.Verification
Built the production output, replicated the copy step, and served it without SPA rewriting to mimic Pages. Unknown URLs (top-level and nested) return HTTP 404 with the styled page. In a browser at a nested unknown URL, React boots into the error boundary with no console errors and no hydration warnings, in both light and dark mode.
🤖 Generated with Claude Code