JS Front-end

All Sanity data traffic routes through our API portal at Communication is done over HTTPS.

Currently, the most feature-complete client library available is our own Sanity Client for Node.js. It covers most API calls, see below for a quick intro on how to use. There is also a PHP client.

If you're on a platform where there is no Sanity Client library available, performing manual HTTP requests is your only option. However, such an effort usually results in a client library. If you write one, please let us know! We'll try our best to keep this documentation up to date with links to all such libraries.



npm install --save @sanity/client


const client = sanityClient({
  projectId: 'your-project-id',
  dataset: 'production',
  token: 'sanity-auth-token' // or leave blank to be anonymous user


client.getDocument('movie_123').then(movie => {
  console.log(`${movie.title} was released ${movie.releaseDate}`)

Perform a query using the client

The above query fetches a single movie document by its ID. Check out the JS client documentation for all the details.

Previous: Example Front-endNext: How to query your documents