0.8.3 • Published 2 years ago

@shopify/hydrogen-plugin-sanity v0.8.3

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

Sanity plugin for Hydrogen

NOTICE: This plugin has been deprecated.

Please use hydrogen-plugin-sanity instead.


This is a plugin for Hydrogen with Sanity. A useSanityQuery React hook with a API similar to useShopQuery is exposed to efficiently and ergonomically fetch data from a Sanity instance.

Getting Started

To add the plugin as a dependency to your project:

yarn add @shopify/hydrogen-plugin-sanity

To fetch data from a Sanity instance:

import {useSanityQuery} from '@shopify/hydrogen-plugin-sanity';

const {data} = useSanityQuery({
  query: gql`
    query product($ids: String!) {
      product: allProduct(where: {id: {in: $ids}}) {
        id
        vendor {
          title
        }
        upc
      }
    }
  `,
  variables: {ids: products.map((product) => product.id)},
});

The useSanityQuery hook knows which Sanity instance to query and authenticate against through the use of two environment variables: VITE_SANITY_ID and VITE_SANITY_TOKEN. Both of these environment variables must be set in order to fetch data with the useSanityQuery hook.

0.8.1

2 years ago

0.8.3

2 years ago

0.8.2

2 years ago

0.6.3

3 years ago

0.8.0

2 years ago

0.7.1

2 years ago

0.6.2

3 years ago

0.6.4

3 years ago

0.7.0

2 years ago

0.6.1

3 years ago

0.6.0

3 years ago

0.5.8

3 years ago

0.5.3

3 years ago

0.5.1

3 years ago

0.4.3

3 years ago

0.4.2

3 years ago

0.4.1

3 years ago