Discussion about implementing routing in Sanity plugins and creating custom pages in Sanity Studio.
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:
- Create a custom tool/plugin that registers routes
- Use the router components for navigation:
StateLink- for navigating with paramsIntentLink- for subpages/intentsLink- for basic navigation back to your plugin's base route
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:
- Create a custom tool plugin
- Register it in your
sanity.config.ts - The plugin will automatically get its own route
- You can render any React component/UI you want within that tool
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:
- Check the official plugin documentation
- Look at the plugin template with routing
- Browse existing plugins on the Sanity Exchange that implement routing
- Review the Router API changelog for the latest capabilities
The Router API is actively being improved, so keep an eye on Studio changelogs for new routing features!
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.