next-superjson
v2.0.0
Published
Automatically transform your Next.js Pages to use SuperJSON, without losing swc support
Downloads
33,929
Readme
Getting started
[!IMPORTANT] Version 2.x requires Next.js 16+. If you're using Next.js 15, install version 1.x instead:
npm install next-superjson@1
Install the library with your package manager of choice, e.g.:
npm install next-superjsonSince this is a companion to SuperJSON, make sure it's also installed:
npm install superjsonAdd the plugin to your next.config.js.
If you don't have one, create it.
const { withSuperjson } = require('next-superjson')
module.exports = withSuperjson()({})That's it! Now you're free to use all values and type supported by SuperJSON in your Next.js Components.
How it works
New Nextjs 12 uses swc to compile user code by default, adding a custom .babelrc file will make Nextjs compile everything using Babel instead (much slower).
This plugin will inject the superjson babel plugin only on files under the pages directory so you can keep using swc for all the other files.

