🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

next-rsc-error-handler

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

next-rsc-error-handler

Webpack plugin that allow to handle RSC errors on the server side

0.2.0
Source
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

next-rsc-error-handler

Webpack plugin that allow to handle RSC errors on the server side.

This plugin requires all the client components to be marked with 'use client;'

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]/, // optional, defaults to /^[A-Z]/
});

export default withRscErrorHandler({
  // next config here
});
  • Add global-server-error.js in your root folder with following content:
/** @type {import('next-rsc-error-handler').GlobalServerError} */
export default function onGlobalServerError(err, ctx) {
  // handling here
}

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) {
  // handling here
}

License

Apache-2.0

Keywords

next

FAQs

Package last updated on 17 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts