lorenzodejong / next-sanity-image

Utility for using responsive images hosted on the Sanity.io CDN with the Next.js image component.
MIT License
149 stars 20 forks source link

Document that @sanity/client is not strictly needed #42

Closed mcky closed 2 years ago

mcky commented 2 years ago

I'm using the package without @sanity/client by providing a SanityClientLike object without problems.

As I'm using graphql I didn't want to bring in the entire sanity client (and rxjs etc), but I didn't realise the first time around that I was able to just provide the project/dataset configuration myself and skip the client

This works just fine for me:

const clientLike: SanityClientLike = {
  clientConfig: {
    projectId: "my-project",
    dataset: "my-dataset",
    apiHost: "https://cdn.sanity.io",
  },
};

const imageProps = useNextSanityImage(clientLike, image);

Happy to make a PR documenting it, although as I saw there's some issues about client versions you could probably go as far as removing it as a peerDep

lorenzodejong commented 2 years ago

If you would like to create a PR for this that would be great. Also note that @sanity/client is currently a peer dependency of this lib. If you don't want to bring in the @sanity/client dependency at all this might also need to change.

lorenzodejong commented 2 years ago

Feel free to open a PR is this is still desired functionality from your end, closing this issue for now.