Structured Content 2022: Join our conference to explore fresh perspectives on content and digital experiences →

How to tell which dataset I'm in with custom actions?

3 replies
Last updated: Oct 31, 2020

Good morning I was wondering is there a way within a custom action to tell in which dataset I'm in? (using the experimental feature for the spaces)

Oct 31, 2020, 12:12 PM

I guess you could get it from the client

import client from "part:@sanity/base/client"

const {dataset} = client.config()

Oct 31, 2020, 1:03 PM

I guess you could get it from the client

import client from "part:@sanity/base/client"

const {dataset} = client.config()

Oct 31, 2020, 1:03 PM

Perfect thanks!!

Oct 31, 2020, 1:16 PM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.