clerk / javascript

Official Javascript repository for Clerk authentication
https://clerk.com
MIT License
1.05k stars 237 forks source link

Global style tags in Next.js prevent Clerk styles from loading during CSR #1025

Closed maxwfreu closed 1 year ago

maxwfreu commented 1 year ago

Package + Version

Dependencies + versions

Provide a json with the dependencies used in your project (copy paste from yarn.lock / package-lock.json) or a github project / template that reproduces the issue.

*Include the @clerk/ packages and their versions!**

Example:

{  
  "dependencies": {
    "react": "18.2.0"
  },
  "devDependencies": {
    "@clerk/nextjs": "^4.11.0",
    "next": "^13.1.6",
  },
  "peerDependencies": {
    "react": "18.2.0"
  }
}

Browser/OS

If applicable e.g. Chrome {version}, Node {version} , Bun {version} , Cloudflare worker {version}

Description

Describe your issue in detail, a demo repository or a sandbox would be great.

Adding a global style tag within _app.tsx will prevent clerk styles from loading during client side rendering. Server side rendering seems unaffected.

To reproduce:

  1. Clone the nextjs starter repo https://github.com/clerkinc/clerk-nextjs-starter.git and install dependencies
  2. Add your clerk .env variables
  3. Update _app.js to include a global style tag:
      <Head>
       ...
        <style jsx global>{`
          html {
            height: 100%;
          }
        `}</style>
         ...
      </Head>
  4. Reload the app
  5. Navigate to the /sign-in page. Click the "Sign up" link to the /sign-up page. Clerk styles will not be applied. Refreshing the page will render the component with the correct styles
perkinsjr commented 1 year ago

User opened a Discord issue, closing this out for discord.