Search Console Configuration
Configure the Search Console plugin options when registering it in your Sanity config.
Plugin Options
// sanity.config.ts
import { defineConfig } from 'sanity'
import { searchConsolePlugin } from 'sanity-plugin-ga-dashboard'
export default defineConfig({
// ...other config
plugins: [
searchConsolePlugin({
// All options are optional
apiUrl: '/api/search-console', // Default: '/api/search-console'
disabled: false, // Default: false
}),
],
})Options Reference
| Option | Type | Default | Description |
|---|---|---|---|
apiUrl | string | '/api/search-console' | URL of the API route that serves Search Console data |
disabled | boolean | false | Disable the plugin entirely — the tool won't appear in the Sanity toolbar. Useful for environment-based toggling. |
Custom API URL
If your API route is at a different path than the default /api/search-console, specify it:
searchConsolePlugin({
apiUrl: '/api/my-search-console'
})Make sure the API route file is at the matching path. For the example above, the file would be at app/api/my-search-console/route.ts.
Environment-based Toggling
Use the disabled option to show the dashboard only in specific environments — for example, production only:
searchConsolePlugin({
disabled: process.env.NODE_ENV !== 'production',
})When disabled is true, the Search Console tool is completely omitted from the Sanity toolbar and no requests are made.
Using Both Plugins
You can use both the GA4 and Search Console plugins together. Each adds its own tool to the Sanity toolbar:
import { defineConfig } from 'sanity'
import {
googleAnalyticsPlugin,
searchConsolePlugin,
} from 'sanity-plugin-ga-dashboard'
export default defineConfig({
// ...other config
plugins: [
googleAnalyticsPlugin({
apiUrl: '/api/analytics',
}),
searchConsolePlugin({
apiUrl: '/api/search-console',
}),
],
})Zero Config
The plugin works with zero configuration if you use the default API route path:
// Simplest configuration — no options needed
plugins: [
searchConsolePlugin(),
]As long as your API route is at /api/search-console and your environment variables are set, the plugin will work out of the box.
TypeScript
The plugin config type is exported if you need it:
import type { SearchConsolePluginConfig } from 'sanity-plugin-ga-dashboard'
const config: SearchConsolePluginConfig = {
apiUrl: '/api/search-console',
disabled: process.env.NODE_ENV !== 'production',
}Environment Variables
The Search Console API route requires these environment variables in your web/frontend .env.local:
| Variable | Description |
|---|---|
GA_SERVICE_ACCOUNT_EMAIL | Service account email (shared with GA plugin) |
GA_PRIVATE_KEY | Service account private key (shared with GA plugin) |
SEARCH_CONSOLE_SITE_URL | Your Search Console property URL (e.g., https://example.com or sc-domain:example.com) |