Skip to content

Auth data is not present on serverside - NextJS App Router #1528

@SimonHylander

Description

@SimonHylander

Package + Version

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore
  • other:

Dependencies + versions

{
  "name": "app-router",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "build": "next build",
    "dev": "next dev",
    "lint": "next lint",
    "start": "next start"
  },
  "dependencies": {
    "@clerk/nextjs": "^4.23.1",
    "@clerk/themes": "^1.7.5",
    "@t3-oss/env-nextjs": "^0.3.1",
    "dotenv": "^16.3.1",
    "encoding": "^0.1.13",
    "next": "^13.4.12",
    "react": "18.2.0",
    "react-dom": "18.2.0",
    "superjson": "1.12.2",
    "svix": "^1.7.0",
    "zod": "^3.21.4"
  }
}

Browser/OS

node 18.16.1

Description

After logging in, all auth properties are null in the server component using the auth() function.
Auth properties are present using a client component with useAuth().
If I try to log auth in the "afterAuth" middleware all properties are also null.

<SignedIn></SignedIn>

only works in client components.

demo project https://github.com/SimonHylander/next-app-router-clerk

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