Next.js Discord

Discord Forum

NextJS15 Error

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
Unhandled Runtime Error

Error: invariant expected layout router to be mounted

Call Stack
OuterLayoutRouter

My imports are from "next/navigation"
The directory structure is correct - hasnt been changed from what the installation has provided
I've tried the suggestions made by copilot chat which include Ensure the GeistSans import is correct: Make sure that GeistSans is correctly imported and used in your layout file.

Check the directory structure: Ensure that your directory structure follows the Next.js 13+ conventions. The layout.tsx file should be in the app directory or a subdirectory within app.

Verify the page.tsx file: Ensure that you have a page.tsx file in the app directory or a subdirectory within app.

Check for any missing dependencies: Ensure that all required dependencies are installed and up-to-date.

Simplify the layout for debugging: Temporarily simplify your layout.tsx file to isolate the issue.

6 Replies

Asian black bearOP
Thanks, that didnt work - I set my project up with supabase like this
https://www.youtube.com/watch?v=wXXTz2eZIoM&ab_channel=Supabase
Asian black bearOP
Is it possible to resolve this? It hasnt happened on every instance I've created
Asian black bearOP
I dont even have the file the error is speaking of - Unhandled Runtime Error

Error: invariant expected layout router to be mounted

Call Stack
OuterLayoutRouter
..\src\client\components\layout-router.tsx (517:3)
I only have a layout.tsx file in my app folder
import DeployButton from "@/components/deploy-button"; import { EnvVarWarning } from "@/components/env-var-warning"; import HeaderAuth from "@/components/header-auth"; import { ThemeSwitcher } from "@/components/theme-switcher"; import { hasEnvVars } from "@/utils/supabase/check-env-vars"; import { GeistSans } from "geist/font/sans"; import { ThemeProvider } from "next-themes"; import Link from "next/link"; import "./globals.css"; const defaultUrl = process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : "http://localhost:3000"; export const metadata = { metadataBase: new URL(defaultUrl), title: "Next.js and Supabase Starter Kit", description: "The fastest way to build apps with Next.js and Supabase", }; export default function RootLayout({ children, }: { children: React.ReactNode; }) { ); }
return ( <html lang="en" className={GeistSans.className} suppressHydrationWarning> <body className="bg-background text-foreground"> <ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange > <main className="min-h-screen flex flex-col items-center"> <div className="flex-1 w-full flex flex-col gap-20 items-center"> <nav className="w-full flex justify-center border-b border-b-foreground/10 h-16"> <div className="w-full max-w-5xl flex justify-between items-center p-3 px-5 text-sm"> <div className="flex gap-5 items-center font-semibold"> <Link href={"/"}>Next.js Supabase Starter</Link> <div className="flex items-center gap-2"> <DeployButton /> </div> </div> {!hasEnvVars ? <EnvVarWarning /> : <HeaderAuth />} </div> </nav> <div className="flex flex-col gap-20 max-w-5xl p-5"> {children} </div> <footer className="w-full flex items-center justify-center border-t mx-auto text-center text-xs gap-8 py-16"> <p> Powered by{" "} <a href="https://supabase.com/?utm_source=create-next-app&utm_medium=template&utm_term=nextjs" target="_blank" className="font-bold hover:underline" rel="noreferrer" > Supabase </a> </p> <ThemeSwitcher /> </footer> </div> </main> </ThemeProvider> </body> </html>