Closed JakiChen closed 8 months ago
[Please fix the bug as soon as possible]: error
__vite_ssr_import_2__.useSanityClient
is not a function
- astro: v3.2.0
- @sanity/astro: v2.0.0
astro@^3.2.0
version, and everything is normal in v3.0.0~v3.1.1.the new API doesn't export a function any more (see here). Remove the brackets, and it should work.
- useSanityClient().fetch(...)
+ sanityClient.fetch(...)
the new API doesn't export a function any more (see here). Remove the brackets, and it should work.
- useSanityClient().fetch(...) + sanityClient.fetch(...)
Thank you,
I already know that there are too many dependent libraries that need to be installed (too unfriendly for a user who does not want to develop the Sanity server). In addition, even if the official reference case is installed, there is still an inexplicable error when loading the detailed page. Its seconds wrong.
As a friendly official plug-in, it should be as efficient and simple as possible. It may be deprecated, it may be best to use the original TS method, or it may seek more friendly headless CMS integration support.
Sorry for the inconvenience! We're working on a fix for this. It should be out this week.
@JakiChen: To your points about “too many dependent libraries” vs. “efficient and simple as possible.” This integration installs the necessary dependencies to easily mount Sanity Studio on a route. This is not the “Sanity server,” but the content editing interface you will have to set up and configure if you're using Sanity, not just for the content store. The dependencies won't be part of your production build unless you use this function, and if you do, only for the given route.
If keeping as few dependencies as possible is important to you, then I suggest installing @sanity/client
or picosanity
, or just fetch
against the HTTP endpoint directly!
Any news about this?
still having the issue with:
"@sanity/astro": "^2.1.4",
"@sanity/client": "^6.8.0",
"astro": "^3.5.2",
"sanity": "3.19.2",
Any news about this?
still having the issue with:
"@sanity/astro": "^2.1.4", "@sanity/client": "^6.8.0", "astro": "^3.5.2", "sanity": "3.19.2",
You can use like this instead:
import { sanityClient } from "sanity:client";
Should be solved in #149 – thanks for reporting! (Astro requires a default export for npx astro add
installation)
[Please fix the bug as soon as possible]: error
__vite_ssr_import_2__.useSanityClient
is not a functionastro.config.mjs
config/index.js
sr/pages/post/index.astro