next-superjson-plugin icon indicating copy to clipboard operation
next-superjson-plugin copied to clipboard

Next 15 compatibility and temporary option to force page router

Open serg-and opened this issue 1 year ago β€’ 5 comments

Bump swc_core to 0.106.* to be in line with [email protected].

next changed the filename metadate making this plugin unable to detect app or page router https://github.com/vercel/next.js/issues/72019.

Added a temporary option to force page router, this will make the plugin incompatible with projects using both routers.

serg-and avatar Oct 29 '24 10:10 serg-and

Any updates on this?

Finkes avatar Nov 14 '24 19:11 Finkes

It seems like a breaking change from upstream.

If that change is intended, we may need to drop router detection feature and should provide an option for the users to select the router type in own hands.

orionmiz avatar Nov 15 '24 00:11 orionmiz

@orionmiz @serg-and a plugin option to manually set the router type would indeed be the most expedient solution

awkaiser-tr avatar Feb 21 '25 21:02 awkaiser-tr

I use both routers in production in several apps, and just want to add that I'd be perfectly happy with manually choosing which router I want this plugin to apply to πŸ‘πŸΌ

vinnymac avatar Mar 07 '25 14:03 vinnymac

I forked and published this plugin with compatibility for Next.js@15, since this plugins to no longer be maintained.

https://github.com/serg-and/superjson-next https://www.npmjs.com/package/superjson-next

serg-and avatar Mar 28 '25 13:03 serg-and

We were digging into this topic a bit deeper and noticed that for react server components (i.e. app router only) there is a much simpler solution without the need for a SWC plugin.

We've published our results as a new open source project called rsc-superjson.

The library provides a simple react hoc that achieves the same result as this SWC plugin but in a more explicit wayβ€”without requiring an SWC plugin.

As a bonus, switching from the SWC plugin to rsc-superjson reduced our build times by approximately 3.5%.

Additionally rsc-superjson also brings support for the return values of server actions

Finkes avatar Mar 28 '25 15:03 Finkes

Ah, we're still on the pages router so won't be useful for us. But seems like a nice solution.

serg-and avatar Mar 28 '25 16:03 serg-and

I forked and published this plugin with compatibility for Next.js@15, since this plugins to no longer be maintained.

https://github.com/serg-and/superjson-next https://www.npmjs.com/package/superjson-next

@orionmiz @siddhsuresh it would be better for the Next / Blitz community if this wasn't necessary, but I understand why it happened RE: how much time has passed πŸ˜“

awkaiser-tr avatar Mar 28 '25 20:03 awkaiser-tr

Enough time for an upstream fix has passed, but the issue still exists. I'll create an plugin option to manually select one router type and create a compatibility table that specifies which plugin versions are available based on the version of Next.js. (This option can be removed by a future upstream bug fix.)

And creating a bundler plugin(webpack, turbopack) also can be considered for the future due to the lack of context provided to compiler plugins. (related issue #90)

orionmiz avatar Apr 04 '25 01:04 orionmiz

@orionmiz your response was a relief to see but, with respect, another month has passed

awkaiser-tr avatar May 08 '25 19:05 awkaiser-tr

@orionmiz @siddhsuresh πŸ™‡πŸ»

  1. 237 days since this community PR was opened to add a "force page router" option

  2. 81 days since maintainer pledged to add option themselves (which is presumably not difficult, just something they're particular about)

If this package is abandoned and users would be best switching to an alternative solution, please update the project README and place a deprecated notice on NPM

awkaiser-tr avatar Jun 23 '25 22:06 awkaiser-tr

πŸͺ¦ πŸ’€ πŸ¦‡

At this point, definitely just use the superjson-next fork offered by @serg-and 😞

  1. ~237~ 269 days since this community PR was opened to add a "force page router" option
  2. ~81~ 113 days since maintainer pledged to add option themselves (which is presumably not difficult, just something they're particular about)

awkaiser-tr avatar Jul 25 '25 18:07 awkaiser-tr

the Next.js team has finally fixed the issue, so we can enable auto router type detection again. pushed a new release of the fork because this repo seems hella dead.

serg-and avatar Jul 28 '25 23:07 serg-and