Tiny Sanity client alternative, if you only need to do queries and only need to support modern browsers.
- Node.js >= 10
- Modern browsers (Edge >= 14, Chrome, Safari, Firefox etc)
npm install --save picosanity
import PicoSanity from 'picosanity'
const client = new PicoSanity({
projectId: 'myProjectId',
dataset: 'myDataset',
apiVersion: '2021-03-25', // use a UTC date string
useCdn: true,
})
client
.fetch('*[_type == $someType]', {someType: 'article'})
.then((articles) => console.log(articles))
.catch((err) => console.error('Oh noes: %s', err.message))
You can load this module as a UMD-bundle from unpkg - https://unpkg.com/picosanity
If used in a global browser context, it will be available as window.PicoSanity
MIT © Espen Hovlandsdal