Running my project locally works totally fine but it does not when I am try to deploy it to vercel.

It says ⨯ sanity/[[...index]]/page.jsx doesn't have a root layout. To fix this error, make sure every page has a root layout. Compiler server unexpectedly exited with code: 1 and signal: null

I tried googling but found no solutions so I deleted the files by sending it to the trash bin but when I do that it is unable to fetch the data from the Sanity back-end. I don't know what to do. Here is my code for the page.jsx:

'use client'

import { NextStudio } from 'next-sanity/studio'
import config from '../../../../sanity.config'

export default function StudioPage() {
  return <NextStudio config={config} />
}
1

There are 1 best solutions below

0
Sehaj Singh Bindra On

So the problem is In Nextjs 13 onwards the layout.tsx or jsx is mandatory so you can fix the issue by using Route Groups for example

enter image description here

So (admin) is route groups and it does not affect the the URL path structure.

for more info: https://nextjs.org/docs/app/building-your-application/routing/route-groups