Skip to content

Commit 43b8ae6

Browse files
devallibusclaude
andcommitted
fix(playground): read session ID from URL directly in onMount
useSearch reactive value isn't hydrated when onMount fires during TanStack Start + SolidJS hydration. Read the session param from window.location.search directly, matching the pattern used by the shaders page for its query param. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 782a9e6 commit 43b8ae6

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

apps/web/src/routes/playground.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createFileRoute, useNavigate, useSearch } from '@tanstack/solid-router'
1+
import { createFileRoute, useNavigate } from '@tanstack/solid-router'
22
import { createServerFn } from '@tanstack/solid-start'
33
import { useServerFn } from '@tanstack/solid-start'
44
import { createSignal, onMount, Show } from 'solid-js'
@@ -28,20 +28,25 @@ export const Route = createFileRoute('/playground')({
2828
})
2929

3030
function PlaygroundPage() {
31-
const search = useSearch({ from: '/playground' })
3231
const navigate = useNavigate()
3332
const fetchSession = useServerFn(getOrCreateSession)
3433
const [session, setSession] = createSignal<PlaygroundSession | null>(null)
3534
const [loading, setLoading] = createSignal(true)
3635

36+
// Read session ID from URL directly — useSearch reactive value isn't
37+
// hydrated yet when onMount fires in TanStack Start + SolidJS.
38+
const initialSessionId = typeof window !== 'undefined'
39+
? new URLSearchParams(window.location.search).get('session') || undefined
40+
: undefined
41+
3742
onMount(async () => {
3843
try {
39-
const result = await fetchSession({ data: { sessionId: search.session } })
44+
const result = await fetchSession({ data: { sessionId: initialSessionId } })
4045
const s = result as PlaygroundSession
4146
setSession(s)
4247

4348
// Update URL with session ID if it changed or was missing
44-
if (search.session !== s.id) {
49+
if (initialSessionId !== s.id) {
4550
navigate({ search: { session: s.id }, replace: true })
4651
}
4752
} finally {

0 commit comments

Comments
 (0)