Skip to content

Conversation

@theVedanta
Copy link
Contributor

Store works out of the box with pretty much the react adapter, only a few changes were needed. Feel free to suggest fixes or co-author!

Making a store preact-adapter should essentially open doors to making preact adapters for more Tanstack libraries, so any help is appreciated here.

@theVedanta theVedanta marked this pull request as ready for review November 27, 2025 14:34
@@ -0,0 +1,97 @@
import { useSyncExternalStoreWithSelector } from 'use-sync-external-store/shim/with-selector.js'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's ok to use uSES shim in preact?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would need to at least switch the import to import { useSyncExternalStore } from 'preact/compat';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right! I totally missed this.

Copy link
Contributor Author

@theVedanta theVedanta Nov 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed this. no longer has the react uSES, but rather preact/compat. But it does use a simpler version of the "with selector" functionality since the original preact/hooks version ships without the with-selector and server-side sync. Let me know if you find something off about the with-selector implementation

ref: https://github.com/preactjs/preact/blob/main/compat/src/hooks.js

Copy link

@rschristian rschristian Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, preact/compat is side-effectful & brings in a bunch of other stuff alongside usage of any API. If there is a need for our impl of uSES (or other APIs) we may be willing to release a separate shim package or separate entry point that consumers can use instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is actually so real. It would be awesome if this can exist. I would love to look into it as well!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rschristian you are a legend - thank you for jumping in here! Let us know how we can assist, but confirmed that it will be helpful. @theVedanta and crew are porting Query, Form, Store, Router, and others to Preact

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've talked about it for years, might finally be time for pure preact/compat/utils or something (name TBD)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be awesome man you're such a goat for this

@theVedanta
Copy link
Contributor Author

This is ready to review now!

Copy link
Member

@crutchcorn crutchcorn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to see some tests using testing-library like we have for React before we merge:

https://github.com/TanStack/store/blob/main/packages/react-store/tests/index.test.tsx

This would give me (personally) better confidence in the useSyncExternalStore custom hook.

@theVedanta
Copy link
Contributor Author

I'd love to see some tests using testing-library like we have for React before we merge:

https://github.com/TanStack/store/blob/main/packages/react-store/tests/index.test.tsx

This would give me (personally) better confidence in the useSyncExternalStore custom hook.

I'm on it 🫡

@nx-cloud
Copy link

nx-cloud bot commented Nov 30, 2025

View your CI Pipeline Execution ↗ for commit 88337db

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 37s View ↗
nx run-many --target=build --exclude=examples/** ✅ Succeeded 17s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-30 18:04:05 UTC

@theVedanta
Copy link
Contributor Author

I'd love to see some tests using testing-library like we have for React before we merge:

https://github.com/TanStack/store/blob/main/packages/react-store/tests/index.test.tsx

This would give me (personally) better confidence in the useSyncExternalStore custom hook.

Wrote the tests, and left a comment on the one that specifically tests the withSelector

@KevinVandy
Copy link
Member

I'm about to update this pr with generated docs

@KevinVandy KevinVandy changed the title PREACT ADAPTER: initial setup -- eslint + vite config + simple plugins feat: add Preact adapter Nov 30, 2025
@KevinVandy KevinVandy merged commit e72d955 into TanStack:main Dec 1, 2025
2 of 3 checks passed
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.

4 participants