Next.js and Vercel - Error! No Output Directory named "dist" found
I can see what's happening here! This is a common confusion when setting up Sanity + Next.js on Vercel. The error you're seeing is related to Vercel's project configuration, not your actual project structure.
The issue is that Vercel is looking for a dist folder because it's been configured (or auto-detected) with the wrong build settings. When you deploy a Next.js application to Vercel, you should NOT be running sanity build as part of your deployment - that command is only for building a standalone Sanity Studio for self-hosting.
Solution: Update Your Vercel Project Settings
Go to your Vercel project settings (Project Settings → General → Build & Development Settings)
Set the correct Framework Preset: Select "Next.js" from the dropdown. This will automatically configure:
- Build Command:
next build(notsanity build) - Output Directory:
.next(notdist) - Install Command: Automatically detected
- Build Command:
If you've manually set an Output Directory, remove it or change it to
.next
Why This Happens
sanity buildgenerates adistfolder containing a standalone Sanity Studionext buildgenerates a.nextfolder containing your Next.js application- The example repo you referenced has
.gitignoreentries for both because it may contain both a Next.js app AND an embedded Studio, but only the Next.js build is deployed to Vercel - When deploying a Next.js app with an embedded Studio (typically at
/studioroute), you only runnext build- Next.js handles bundling the Studio as part of your application
Quick Check
If your project structure looks like this:
/app or /pages (Next.js routes) /sanity (Sanity schema/config) next.config.js sanity.config.ts
Then you're building a Next.js app with embedded Studio, and you should use Next.js build settings on Vercel, not standalone Studio settings.
After updating these settings in Vercel, trigger a new deployment and it should build successfully!
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.