Skip to content

404 Pages Intermittently Return Blank After Adding Clerk #5001

Description

@michael-land

Which project does this relate to?

Start

Describe the bug

I'm new to TanStack Start and Router, and migrating a new project from React Router v7 has been a good experience overall. However, I encountered some issues and spent hours trying to figure out what was happening. My guess is that it’s caused by a hydration mismatch or a component being unmounted unexpectedly.

After integrating Clerk authentication, 404 pages sometimes return blank instead of showing the expected notFoundComponent. The behavior is inconsistent—sometimes it works, sometimes it just shows a white screen.

Key points:

  1. The issue is intermittent: the same URL sometimes works, sometimes doesn’t.
  2. Routes work fine without Clerk.
  3. The issue only appears after Clerk integration.

Your Example Website or App

https://github.com/michael-land/tanstack-start-with-clerk-hydration-issue

Steps to Reproduce the Bug or Issue

  1. Add Clerk authentication to TanStack Start project
  2. Add Clerk Environment Variables in .env
VITE_CLERK_PUBLISHABLE_KEY=pk_test_xxxxxx
CLERK_SECRET_KEY=sk_test_xxxxxx
  1. Navigate to a non-existent route (e.g., /posts/non-existent-id)
  2. Sometimes shows the notFoundComponent, sometimes shows blank page

Expected behavior

Should consistently show the notFoundComponent

Screenshots or Videos

tanstack-clerk.mp4

0:03 - 0:14 refreshing post index page working fine
0:14 - 0:20 refreshing post not found page shows empty white screen

Platform

  • Router / Start Version: 1.131.27
  • OS: macOS
  • Browser: Arc
  • Browser Version: Version 1.108.0 (66882)
    Chromium Engine Version 139.0.7258.128
  • Bundler: Vite
  • Bundler Version: 7.1.3

Additional context

Environment

    "@tanstack/react-query": "^5.85.5",
    "@tanstack/react-query-devtools": "^5.85.5",
    "@tanstack/react-router": "^1.131.27",
    "@tanstack/react-router-ssr-query": "^1.131.27",
    "@tanstack/react-router-devtools": "^1.131.27",
    "@tanstack/react-start": "^1.131.27",
    "@clerk/tanstack-react-start": "0.22.3",

    "vite": "^7.1.3",
    "vite-tsconfig-paths": "^5.1.4"


Activity

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