React Router (Remix) quick start

Query content with GROQ

Content from Sanity is typically fetched as JSON from your hosted dataset using the GROQ query language.

1Write your first GROQ query

Open Vision in your studio's navigation bar and paste this query into the Query pane.

  • * represents all documents in a dataset as an array.
  • [_type == "post"] represents a filter to only return matching documents.
  • { _id, title, slug, publishedAt } represents a projection which defines the attributes from those documents that you want to include in the response.
  • [0...10] represents a slice that limits the response to the first 10 documents.

2Run the query in Vision

Click Fetch to see the JSON output in Result. Vision returns the post document you published.

Vision queries the raw perspective by default, so results include draft documents. A draft's _id begins with the drafts. prefix. Unauthenticated requests, including most front-end queries, never return drafts.

For more query syntax, see GROQ introduction.

Was this page helpful?