Join live – Get insights, tips, + Q&A from Sanity developers on our latest releases

Issue with importing Sanity in a Next.js app when deploying to Vercel.

9 replies
Last updated: Jan 27, 2023
hello folks,I create a blog and it work fine locally,
I deploy studio in sanit with
npm run deploy
that will run
snaity deploy
then I'll try to deploy the FE (nextjs) to vercel I get this errorhere is my file structure
any hints please?
Jan 24, 2023, 10:44 PM
check to make sure
is in package.json under dependencies
Jan 24, 2023, 11:17 PM
"dependencies": {
    "@sanity/code-input": "^3.0.1",
    "@sanity/vision": "^3.0.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-is": "^18.2.0",
    "sanity": "^3.0.0",
    "styled-components": "^5.2.0"
yes it's there and I run same command as build, it work locally
Jan 24, 2023, 11:20 PM
I have this in my project and it's working, so you may need to drop the
part of that import. See:
import { defineConfig } from "sanity";
Jan 25, 2023, 3:29 AM
thanks User for reply, did you deploy it to vercel ?is your sanity studio in the same root folder as nextjs or in different folder?
ah ok I'll try to remove
Jan 25, 2023, 3:32 AM
Yes, I'm deploying to Vercel, however I've split my Sanity Studio and my Next.js app into two separate projects/repos.
Jan 25, 2023, 4:52 AM
Thanks, this is was my issue, the sanity project was in the same repo of nextjs
Jan 26, 2023, 4:29 AM
monorepos are possible too πŸ™‚ thats what I do most of the time, the only issue here was the import!
Jan 26, 2023, 7:07 PM
Can you then also have all dependencies in the package json at the root, and have a subdirectory containing the sanity configs? I was trying to set that up but couldnt figure out a way to do that
Jan 26, 2023, 7:09 PM
user J
if you could help where do you see that the issue was the import and how can I fix it, it help a lot, FYI locally it work fine, get this error when trying to deploy it to vercel.
Jan 27, 2023, 2:03 AM

Sanity– build remarkable experiences at scale

Sanity is a modern headless CMS that treats content as data to power your digital business. Free to get started, and pay-as-you-go on all plans.

Was this answer helpful?

Categorized in