Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rexxars/picosanity
Tiny Sanity client alternative should you only need to do queries
https://github.com/rexxars/picosanity
client headless sanity
Last synced: 12 days ago
JSON representation
Tiny Sanity client alternative should you only need to do queries
- Host: GitHub
- URL: https://github.com/rexxars/picosanity
- Owner: rexxars
- License: mit
- Created: 2018-06-18T07:21:44.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2023-10-17T19:00:08.000Z (about 1 year ago)
- Last Synced: 2024-10-11T07:13:04.946Z (27 days ago)
- Topics: client, headless, sanity
- Language: JavaScript
- Homepage:
- Size: 1.14 MB
- Stars: 74
- Watchers: 2
- Forks: 3
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-sanity - `picosanity` - Tiny Sanity client alternative, if you only need to do queries and only need to support modern browsers. (Related projects / Studio Inspiration)
README
# picosanity
[![npm version](https://img.shields.io/npm/v/picosanity.svg?style=flat-square)](http://browsenpm.org/package/picosanity)[![npm bundle size](https://img.shields.io/bundlephobia/minzip/picosanity?style=flat-square)](https://bundlephobia.com/result?p=picosanity)
Tiny Sanity client alternative, if you only need to do queries and only need to support modern browsers.
## Targets
- Node.js >= 10
- Modern browsers (Edge >= 14, Chrome, Safari, Firefox etc)## Installation
```bash
npm install --save picosanity
```## Usage
```js
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))
```## UMD bundle
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`## License
MIT © [Espen Hovlandsdal](https://espen.codes/)