Comments (4)
Actually, after some digging I see that Next.js internally uses an error boundary that is redirect-aware, but not in a way that I can re-use in my repo. Have you considered exporting RedirectBoundary so that devs can use it directly?
That would allow me to make an in-house error boundary in which the redirect always comes first:
export const MyErrorBoundary = ({
children,
...props
}: SentryErrorBoundaryProps => (
<SentryErrorBoundary {...props}>
<NextRedirectBoundary>
{children}
</NextRedirectBoundary>
</SentryErrorBoundary>
)
from next.js.
Have you considered exporting RedirectBoundary so that devs can use it directly?
Everything in next.js is importable. It's might not typed but it's still exported.
next.js/packages/next/package.json
Lines 11 to 12 in dcf8f04
Have you tried to import it?
from next.js.
Oh, good call! This works:
import { RedirectBoundary } from 'next/dist/client/components/redirect-boundary'
from next.js.
Ok, I've had a couple of days to play with it and I've come to the conclusion that even with the boundaries in place (as I've suggested above) this is still pretty error prone and should not be recommended as a pattern. I think the docs should discourage it.
from next.js.
Related Issues (20)
- next build --no-mangling keeps mangling
- CSP with nonce does not work for page router HOT 1
- Turbopack doesn't correctly handle catch-all segments in nested route groups HOT 2
- Server Actions that are hybrid types are compiled to `{}` causing `TypeError`
- Rechart breaks in Nextjs 15-rc.0 HOT 3
- Error boundaries ignored in Production with `dynamicParams = true` HOT 1
- Build fails when object keys contain Japanese middle dots(・) in v14.2 HOT 1
- Latest starter-example project is containing invalid package references. HOT 2
- Impossible to use worker_thread (server side) due to wrong path
- Unexpected Caching Behavior with revalidate in Next.js HOT 1
- Nested intercepted routes fail
- Draft Mode does not work in Middleware HOT 3
- Route group as a root of dynamic route shows 404 HOT 1
- Build issue with subpath imports of internal "compiled" package HOT 14
- OOMKill is hidden during docker-based next build, build appears successful but isn't. HOT 3
- Generating static pages (0/6) [= ]G [AggregateError] HOT 5
- RSC Fetch Logging deduplicates requests if they share the same URL, even if POST bodies are different HOT 3
- ### Goals HOT 1
- expect is not defined when running next.js with Jest
- Css and JS file not work when I deploy nextjs to vercel, I don't know what happened? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next.js.