Skip to content

Conversation

@elohmeier
Copy link
Contributor

🎯 Changes

When useLiveQuery receives a getter function that returns null during SSR (e.g., () => documentsCollection where documentsCollection is initially null), the implementation was trying to spread null into a config object, causing an error.

This adds a null/undefined check before spreading to return null early, matching how react-db and solid-db handle this case.

Before: useLiveQuery(() => nullableCollection) throws when getter returns null
After: Returns empty/idle state, then updates reactively when collection becomes available

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

When a collection getter returns null during SSR, the implementation
was trying to spread null into a config object, causing an error.
Add a null/undefined check before spreading to return null early,
matching how react-db and solid-db handle this case.
@changeset-bot
Copy link

changeset-bot bot commented Jan 29, 2026

🦋 Changeset detected

Latest commit: 33d87a3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/svelte-db Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 29, 2026

More templates

@tanstack/angular-db

npm i https://pkg.pr.new/@tanstack/angular-db@1195

@tanstack/db

npm i https://pkg.pr.new/@tanstack/db@1195

@tanstack/db-ivm

npm i https://pkg.pr.new/@tanstack/db-ivm@1195

@tanstack/electric-db-collection

npm i https://pkg.pr.new/@tanstack/electric-db-collection@1195

@tanstack/offline-transactions

npm i https://pkg.pr.new/@tanstack/offline-transactions@1195

@tanstack/powersync-db-collection

npm i https://pkg.pr.new/@tanstack/powersync-db-collection@1195

@tanstack/query-db-collection

npm i https://pkg.pr.new/@tanstack/query-db-collection@1195

@tanstack/react-db

npm i https://pkg.pr.new/@tanstack/react-db@1195

@tanstack/rxdb-db-collection

npm i https://pkg.pr.new/@tanstack/rxdb-db-collection@1195

@tanstack/solid-db

npm i https://pkg.pr.new/@tanstack/solid-db@1195

@tanstack/svelte-db

npm i https://pkg.pr.new/@tanstack/svelte-db@1195

@tanstack/trailbase-db-collection

npm i https://pkg.pr.new/@tanstack/trailbase-db-collection@1195

@tanstack/vue-db

npm i https://pkg.pr.new/@tanstack/vue-db@1195

commit: 33d87a3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant