Skip to content

Conversation

@fezproof
Copy link

@fezproof fezproof commented Nov 15, 2025

🎯 Changes

The main change in this PR is that tanstack solid db now has Suspense support by default. This is more inline with the rest of the solid ecosystem and tanstack query.

// Use Suspense boundaries
const todosQuery = useLiveQuery((q) =>
  q.from({ todos: todoCollection })
)

return (
  <Suspense fallback={<div>Loading...</div>}>
    <For each={todosQuery()}>
      {(todo) => <li key={todo.id}>{todo.text}</li>}
    </For>
  </Suspense>
)

Updated the API for solid js to be more inline with solid js createResource. This is a breaking change to the API, as status, collection, and the various loading states are now getters instead of Accessors. This actually kinda simplifies the API, especially for collections.

// Access collection methods directly
const existingQuery = useLiveQuery(() => existingCollection)

// Use collection for mutations
const handleToggle = (id) => {
  existingQuery.collection.update(id, draft => { draft.completed = !draft.completed })
}

✅ 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).

@changeset-bot
Copy link

changeset-bot bot commented Nov 15, 2025

🦋 Changeset detected

Latest commit: fbbcaed

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

This PR includes changesets to release 2 packages
Name Type
@tanstack/solid-db Minor
@tanstack/db-example-solid-todo 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

@fezproof fezproof marked this pull request as ready for review November 15, 2025 15:41
@KyleAMathews
Copy link
Collaborator

@MAST1999 what do you think?

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 17, 2025

More templates

@tanstack/angular-db

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

@tanstack/db

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

@tanstack/db-ivm

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

@tanstack/electric-db-collection

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

@tanstack/offline-transactions

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

@tanstack/powersync-db-collection

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

@tanstack/query-db-collection

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

@tanstack/react-db

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

@tanstack/rxdb-db-collection

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

@tanstack/solid-db

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

@tanstack/svelte-db

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

@tanstack/trailbase-db-collection

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

@tanstack/vue-db

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

commit: 5cfec9e

@KyleAMathews
Copy link
Collaborator

Also relevant — working on this https://github.com/TanStack/db/pull/842/files#diff-6bb6eea8d2771d74392090da8774873368fa5dca9cb915e442adc3a05e3b9b89

@MAST1999
Copy link
Contributor

Thanks for the work.

I've been meaning to fix this for some time.
Other than the comment I left the changes look good.

The only other thing that worries me is changing the returned interface. If someone is already using the old one they'll have a lot of work migrating to the new output.

@fezproof
Copy link
Author

I don’t see your comment @MAST1999
I could add data back as an accessor to enable a more stable update, and mark it deprecated? Should make updating a bit smoother

@MAST1999
Copy link
Contributor

MAST1999 commented Nov 18, 2025

I could add data back as an accessor to enable a more stable update, and mark it deprecated? Should make updating a bit smoother

Sounds good!

The comment is on code, I left a review.
Why can't we use createComputed instead of createEffect. The effect will run after the render and it might cause more renders afterward.

@fezproof
Copy link
Author

fezproof commented Nov 20, 2025

I could add data back as an accessor to enable a more stable update, and mark it deprecated? Should make updating a bit smoother

This is done now

The comment is on code, I left a review.

No reviews have been made on this PR, perhaps you forgot to hit submit @MAST1999

Why can't we use createComputed instead of createEffect. The effect will run after the render and it might cause more renders afterward.

If we use createComputed, it will run on render which means it also runs in SSR. Currently tanstack db doesn't support SSR, but this could be a huge pain in the future. createEffect also is designed for this kind of subscription to events, as it does not block rendering. Solid isn't React, only the data that changes will be re-rendered, making this not really a problem.

@KyleAMathews
Copy link
Collaborator

We are going to be adding support for SSR soon to react btw. The patterns should be easy I assume to port to solid.

@MAST1999
Copy link
Contributor

No reviews have been made on this PR, perhaps you forgot to hit submit @MAST1999

Damn it, I don't use GitHub too much, my bad. I indeed missed it.

LGTM

@MAST1999
Copy link
Contributor

We are going to be adding support for SSR soon to react btw. The patterns should be easy I assume to port to solid.

Yep, should be really easy.
Give me a heads up and I'll update the Solid adapter.

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.

3 participants