next-rsc-error-handler
Webpack plugin that allow to handle RSC errors on the server side.
This plugin does not allow to use dual client and server components
Get started
- Install the dependency
npm i next-rsc-error-handler
- In your next config add the plugin:
import { rscErrorHandler } from "next-rsc-error-handler";
const withRscErrorHandler = rscErrorHandler({
componentName: /^_?[A-Z]/,
});
export default withRscErrorHandler({
});
- Add
global-server-error.js
in your root folder with following content:
export default function onGlobalServerError(err, ctx) {
}
Alternatively, you can use global-server-error.ts
with:
import { type GlobalServerErrorContext } from 'next-rsc-error-handler';
export default function onGlobalServerError(err: unknown, ctx: GlobalServerErrorContext) {
}
License
Apache-2.0