Unknown type: svgUploadPreview. Valid types are: page, goal, array...
The issue you're experiencing is that you're trying to use an old plugin designed for Sanity Studio v2, but the error and your code structure suggest you're working with a modern version of Sanity. The plugin you mentioned (sanity-plugin-inline-svg) and the type name svgUploadPreview are from an outdated plugin that's no longer compatible.
The good news is there's a modern, actively maintained version of this plugin for Sanity Studio v3!
Solution: Use the Modern Plugin
You need to use @focus-reactive/sanity-plugin-inline-svg-input instead. Here's how to fix your setup:
1. Uninstall the old plugin and install the new one
# Remove the old plugin
sanity uninstall sanity-plugin-inline-svg
# Install the modern plugin
npm install @focus-reactive/sanity-plugin-inline-svg-input2. Update your sanity.config.js (or .ts)
Add the plugin to your Sanity configuration:
import { defineConfig } from 'sanity'
import { inlineSvgInput } from '@focus-reactive/sanity-plugin-inline-svg-input'
export default defineConfig({
// ... your other config
plugins: [
inlineSvgInput(),
// ... your other plugins
],
})3. Update your schema (schemas/goal.js)
Change the field type from svgUploadPreview to inlineSvg:
import { GiArcheryTarget as icon } from 'react-icons/gi';
export default {
name: 'goal',
title: 'Objectifs',
type: 'document',
icon,
fields: [
{
name: 'svgUpload',
title: 'IcƓne',
type: 'inlineSvg', // Changed from 'svgUploadPreview'
},
{
name: 'title',
title: 'Titre',
type: 'string',
},
{
name: 'list',
title: 'Liste de capacitƩs',
type: 'array',
of: [{ type: 'string' }],
},
],
};4. Remove the import line
You no longer need to import anything in your schema file - the plugin registers the type globally when added to your config. Remove this line from your goal.js:
import svgUploadPreview from 'sanity-plugin-inline-svg'; // Remove thisWhy This Happened
The old sanity-plugin-inline-svg plugin (which used the svgUploadPreview type) was built for Sanity Studio v2. Your code structure using part:@sanity/base/schema-creator confirms you were following v2 patterns, but if you're on a newer Sanity version, you need the v3-compatible plugin.
The modern plugin uses the type name inlineSvg instead of svgUploadPreview, and it's installed and configured differently to work with Sanity Studio v3's architecture.
Bonus: Preview in Arrays
If you want to display SVG previews in array fields, the new plugin includes a handy component called InlineSvgPreviewItem. Check out the GitHub documentation for examples on how to use it for rich array previews with your SVG icons.
After making these changes, restart your Sanity Studio and you should be good to go! š
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.