Crash error on Media and Dashboard tabs in new Sanity project

2 replies
Last updated: Mar 20, 2024
Hi everyone! hope all of you are well!getting the crash error on Media and Dashboard tab when open it. in very new created Sanity project.
is anyone help out ?
AI Update

Sorry to hear you're experiencing crashes with the Media and Dashboard tabs in your new Sanity project! This is a known issue that's typically related to React 19 compatibility with certain plugins. Here's what's likely happening and how to fix it:

The Problem

Based on the error patterns you're seeing, this is most commonly caused by:

  1. React 19 compatibility issues - The sanity-plugin-media and @sanity/dashboard plugins may not be fully compatible with React 19 yet
  2. Outdated package versions - Older versions of Sanity Studio and plugins may have compatibility issues

Solutions to Try

Update Sanity Studio, the media plugin, and React to their latest compatible versions:

npm install sanity@latest sanity-plugin-media@latest react@latest react-dom@latest

According to Sanity's React 19 compatibility guidance, most official plugins now support React 19, but you need the latest versions.

2. If Using React 19, Consider Downgrading to React 18.3

If updating doesn't work, React 18.3 is currently the most stable version for Sanity:

npm install react@18.3.1 react-dom@18.3.1 --save-exact

3. Check for the "Duplicate Context" Error

If you're seeing an error about "Duplicate instances of context" with the media library, this indicates you might have multiple versions of Sanity packages installed. Run:

npm dedupe
# or if using pnpm
pnpm dedupe

4. Verify Your Package Versions

Check your package.json to ensure you have:

  • sanity: ^3.92.0 or later (for React 19 support)
  • sanity-plugin-media: ^2.3.2 or later
  • @sanity/dashboard: latest version

5. Clear Cache and Reinstall

Sometimes a clean install helps:

rm -rf node_modules package-lock.json
npm install

If You're Using the Community Media Plugin

Note that sanity-plugin-media is a community plugin (not an official Sanity plugin). If issues persist, you might want to consider:

  1. Using Sanity's built-in asset management instead
  2. Upgrading to Media Library (Enterprise add-on) which has better support and features
  3. Checking the plugin's GitHub issues for known problems

For the Dashboard Plugin

The @sanity/dashboard plugin has had some React 19 compatibility issues. Make sure you're on the latest version, and check the Sanity changelog for updates.

Let us know which versions you're running and what specific error messages you're seeing, and we can provide more targeted help!

Show original thread
2 replies
πŸ‘‹ Can you share how you configured the plugin? What versions are you running?
i have fixed that, actually the issue due to styled-components lib. downgrade it and working fine. Thank You

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.

Was this answer helpful?