Sanity Pioneers: Get early access to betas, extra AI credits, and a direct line to the engineering team. Apply now

Sanity plugins with routing implementation using @sanity/state-router?

10 repliesLast updated: Nov 29, 2025

Anyone know of any sanity plugins that implements routing? Would like to see how it's done. Is using
@sanity/state-router
the recommended way?
AI Update

Based on the discussion you linked and the recent Sanity Studio v3 changes, here's what you need to know about implementing routing in Sanity plugins:

Using @sanity/state-router and the Router API

Yes, the Router API (which includes @sanity/state-router concepts) is the recommended way to handle routing in Sanity Studio plugins. As of Studio v3.81.0 (March 2025), there have been significant improvements to the Router API.

Example Implementation

The best reference is the plugin-template-tool-with-routing template mentioned in the community discussion. This shows how to:

Recent Router API Improvements (v3.81.0)

The Router API now has better support for stickyParams via the useRouter hook:

const router = useRouter()

// Navigate with sticky params
router.navigate({
  stickyParams: {paramKey: 'paramValue'}, 
  replace: false
})

// Or combine with state updates
router.navigate({
  stickyParams: {paramKey: 'paramValue'},
  state: {
    stateKey: 'stateValue'
  }
})

Note: navigateStickyParams from sanity/router is now deprecated - use the navigate method with options instead.

Creating Custom Pages

To create a custom page at a route like /mycustompage (similar to /desk), you need to:

The community member in your linked discussion confirmed this is possible - you create a plugin tool that renders custom UI and handles its own routing internally.

Finding More Examples

Unfortunately, as noted in the discussion, documentation is limited. Your best bet is to:

The Router API is actively being improved, so keep an eye on Studio changelogs for new routing features!

Show original thread
10 replies

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions