Skip to content

stylisPluginRSC not working on Nextjs navigations #5838

Done

Description

@laurenskling

I'm trying to go 6.4+
but the ...of :not([data-styled]) selectors aren't working reliably.

Removing the Registry fixes it. (it's a copy of the example from the Next docs) (this was a false positive)

When navigating to another page, these :nth-child fixes are not added to the styles.

Activity

  1. pullfrog commented on Oct 16, 2026

    @pullfrog
  2. quantizor commented on Oct 16, 2026

    @quantizor
    Contributor

    Thanks for the report. I can't reproduce this yet. Nested StyleSheetManagers inherit the parent's stylisPlugins from 6.4.0, and a test with an outer manager using stylisPluginRSC and an inner one using sheet passes on 6.6.0.

    To narrow it down, could you share:

    • the exact styled-components and Next.js versions
    • where your registry component and your styled components live (server components or 'use client' files)
    • a minimal repro, if you can

    One guess: the registry runs in the client layer, where the plugin passed by the server-side manager doesn't reach it. As a workaround, try passing the plugin inside the registry component:

    <StyleSheetManager sheet={styleSheet.instance} stylisPlugins={[stylisPluginRSC]}>

    Let me know whether that helps.

  3. laurenskling commented on Oct 16, 2026

    @laurenskling
    Author

    Small update: it only happens on navigations. Directly opening the page works. So it's something with the injected style tags on navigations.

    6.6.0 on Next "^16.3.0"
    But I've seen this in trying to upgrade before. So it was in 6.4/6.5 too I guess.

    I use both server SCs and client SCs. I don't see how I can work around my styled.button with an onClick (making it mandatory to use client)

    adding the plugin to the registry component doesn't help.

  4. changed the title [-]stylisPluginRSC not working when StyledComponentsRegistry is inside[/-] [+]stylisPluginRSC not working on Nextjs navigations[/+] on Oct 17, 2026
  5. laurenskling commented on Oct 17, 2026

    @laurenskling
    Author

    Edited my report. It's not about the registry at all. I was just opening new links in new tabs making them work as a false positive.

    it's fully about navigations.

  6. quantizor commented on Nov 6, 2026

    @quantizor
    Contributor

    @laurenskling I decided to introduce a new API for this, see #5865

    It'll be available in the next pre-release which should go out in like 10 mins or so.

    Feedback appreciated!

  7. laurenskling commented on Nov 9, 2026

    @laurenskling
    Author

    Seems to be working fine!

    Just to be sure, this means i would no longer have to wrap my code in <StyleSheetManager stylisPlugins={[stylisPluginRSC]}>, right?

  8. quantizor commented on Nov 9, 2026

    @quantizor
    Contributor

    Correct, you only need to use it if you want to override a particular subtree.

    I'll be pushing some more 6.x prerelease changes soon too, stay tuned!

  9. quantizor commented on Nov 25, 2026

    @quantizor
    Contributor

    6.7 is now out!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions