Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using the sanity client on client side (React components) #59

Open
lokkeestudios opened this issue Sep 11, 2023 · 3 comments
Open

Using the sanity client on client side (React components) #59

lokkeestudios opened this issue Sep 11, 2023 · 3 comments
Labels

Comments

@lokkeestudios
Copy link

I am currently in the process of migrating to @sanity/astro and I was wondering how I can access the sanity client in my React components (with active client directives) / on the client side?
@sanity/astro introduces the useSanityClient() function, which makes the sanity client accessible to .astro templating files, but in my case I am passing the fetched Sanity CMS data from a .astro file down to a React .tsx component, which worked before (using the @sanity/client package), but now seems to fail: [@sanity/astro]: sanityClientInstance has not been initialized correctly.

Help on this matter is very much appreciated!
Thank you in advance 😊

@jedifunk
Copy link

what's the status of this? is it safe to update the plugin to current version? i'm still sitting on v1.3.0 as i have a React component that uses the sanity client.

@lokkeestudios
Copy link
Author

@jedifunk To my knowledge it should be safe for you to update to the current version, at least everything works like a charm for me. Been using the sanity client in multiple React components without any issues. Proper types are shipped as of recent updates as well, in case you are using TypeScript 😊

@jedifunk
Copy link

excellent, thank you

@stipsan stipsan added the triaged label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants