Skip to content

Wrapping redirect in ClerkProvider leads to spurious redirect #2646

@xixixao

Description

@xixixao

Preliminary Checks

Reproduction / Replay Link

https://github.com/xixixao/bug-clerk-next-redirect

Publishable key

pk_test_cHJvcGVyLXdoaXBwZXQtNzcuY2xlcmsuYWNjb3VudHMuZGV2JA

Description

  1. npm run dev
  2. Sign in or sign up
  3. Wait a second, and observe that you are redirected to an invalid URL that doesn't live under the configured basePath

This was super hard to debug, but in the end what I had was weird, basically my layout was at the wrong level. Still wanted to share it in case someone else runs into this. Looks like nesting a redirect, or streaming server component, under ClerkProvider leads to weird behaviors.

Environment

System:
    OS: macOS 14.2.1
    CPU: Apple M1
  Binaries:
    Node: 18.17.0 - ~/Library/Caches/fnm_multishells/2125_1705529595263/bin/node
    npm: 9.6.7 - ~/Library/Caches/fnm_multishells/2125_1705529595263/bin/npm
    pnpm: 8.7.4 - /opt/homebrew/bin/pnpm
  Browsers:
    Chrome: 120.0.6099.234
    Safari: 17.2.1
  npmPackages:
    @clerk/nextjs: ^4.29.4 => 4.29.4
    @types/node: ^20 => 20.11.5
    @types/react: ^18 => 18.2.48
    @types/react-dom: ^18 => 18.2.18
    autoprefixer: ^10.0.1 => 10.4.17
    eslint: ^8 => 8.56.0
    eslint-config-next: 14.1.0 => 14.1.0
    next: 14.1.0 => 14.1.0
    postcss: ^8 => 8.4.33
    react: ^18 => 18.2.0
    react-dom: ^18 => 18.2.0
    tailwindcss: ^3.3.0 => 3.4.1
    typescript: ^5 => 5.3.3

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