Nextjs 14 experiences full page loading due to the presence of multiple root layouts

The issue I'm facing involves a full page load when navigating between two root layout pages

In my Next.js application (NextJS 14), I have created two root layouts. However, when moving from the first layout to the second layout, it triggers a complete page reload, preventing me from utilizing React context.

For more information on multiple root layouts, you can refer to the documentation here:

https://nextjs.org/docs/app/building-your-application/routing/route-groups#creating-multiple-root-layouts

I am seeking solutions to resolve this issue. Any advice would be greatly appreciated.

Answer №1

It is noted in the reference document that:

Transitioning between multiple root layouts will result in a full page refresh instead of a client-side navigation. For instance, moving from /cart which uses app/(shop)/layout.js to /blog which utilizes app/(marketing)/layout.js will trigger a full page reload. This rule only applies to scenarios with multiple root layouts.

This is an important point to keep in mind.

In essence, when you have two distinct HTML structures (starting from the root <html> tag), it's natural to expect this behavior.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The following middleware fails to transmit cookies received from the server

After a successful login to my Django backend, an httpOnly cookie is returned which is necessary for accessing protected routes in the Next app. To manage this, I have implemented a middleware that checks if a user is trying to access a protected route. If ...

Transform a dynamic web page into a static one using Next.js

Utilizing Next.js and React.js, I create dynamic web pages. Specifically, I generate user-related web pages that need to be updated when there are changes in the user data. How can I generate static HTML pages from this updated data within Next.js? Are the ...

How can I populate an array using values from a different array in Angular?

I am facing an issue with populating three other arrays based on the property 'game type' from my array called 'my games'. Here is an example of the structure of the 'my games' array: hideScore: true, started: true, startedAt: ...

Importing/Requiring an External Module in Typescript Node using a Symbolic Link in the

I am in the process of migrating a Node + Express application to TypeScript and have encountered an issue with using external modules. Previously, I was utilizing the "symlink trick" to avoid dealing with relative paths. This is how it used to work withou ...

Automated page redirection is not supported in Next.js i18n

Why does the homepage redirect correctly, but not the subpages? For example, when my browser language is set to French: When I open the homepage example.com, I am automatically redirected to example.com/fr - which is working fine! However, if I open a su ...

Combining React with Typescript allows for deep merging of nested defaultProps

As I work on a React and Typescript component, I find myself needing to set default props that include nested data objects. Below is a simplified version of the component in question: type Props = { someProp: string, user: { blocked: boole ...

Guide on creating a zodiac validator that specifically handles properties with inferred types of number or undefined

There are some predefined definitions for an API (with types generated using protocol buffers). I prefer not to modify these. One of the types, which we'll refer to as SomeInterfaceOutOfMyControl, includes a property that is a union type of undefined ...

How to simulate a particular class from a node package using Jest mocks

In my project, I'm looking to specifically mock the Socket class from the net node module. The documentation for this can be found here. Within my codebase, there is a class structured similar to the following... import { Socket } from 'net&apo ...

What is the process for obtaining the access token generated by supabase authentication?

Currently utilizing Next.js 13 alongside Supabase v2, I have successfully generated an access token. However, the issue arises as the automatically created access token is not configured for the "localhost" domain, rendering it unreadable and inaccessible. ...

I'm encountering a 404 error on Next.js localhost:3000

Embarking on a fresh project in Next.js, my folder structure looks like this: https://i.stack.imgur.com/HhiJo.png However, upon navigating to localhost:3000, I am greeted with a 404 error screen. It seems there is an issue with the routing, but unfortuna ...

What is the best way to convert the NextJS router.query.id to a string?

As a newcomer to TypeScript and the T3 stack (React Query / Tanstack Query), I am facing an issue with typing companyId as string. I want to avoid having to type companyId as string every time I use it in my code, but I'm struggling to find the best p ...

React Redux Bundle with Hot Reload Feature

Working on a project written in TypeScript with the React and Redux framework, I'm familiar with webpack and its middleware libraries for hot reloading. My question arises when considering how my TypeScript code is first converted to JSX through gulp ...

Issue with accessing Next.js API endpoint in Docker container

My issue is: I recently created a basic web page using Next.js. I fetch some content from /pages/api/ endpoints in JSON format and display it on various pages and components. Building the project locally (npm run dev or npm run start) works perfectly fine ...

Fetching an item from Local Storage in Angular 8

In my local storage, I have some data stored in a unique format. When I try to retrieve the data using localStorage.getItem('id');, it returns undefined. The issue lies in the way the data is stored within localStorage - it's structured as a ...

The use of dates (YYYY-MM-DD) as identifiers in HTML/Angular 2 is causing issues

I have successfully created a calendar using html in Angular 2, and now I am looking to incorporate events into it. These events should be able to color specific days, add a dot inside the cell, or something similar. I have a json file that contains the ev ...

What is the best way to incorporate a splatter image within an MDX blog post?

I am working on an MDX blog where I render a blog post. pages/index.tsx <main className="flex min-h-screen dark:bg-black"> <div className="wrapper mb-24 gap-8 px-8 lg:grid lg:grid-cols-[1fr,70px,min(70ch,calc(100%-64 ...

Middleware in Next.js is failing to accept cookies sent from a subdomain API

Running my API service on https://api.example.com and the Next.js app deployed to Vercel bound to https://example.com, I also have a middleware in place to check protected paths. export function middleware(request: NextRequest) { const isAuthenticated = ...

Creating a setup with Angular 2+ coupled with Webpack and a Nodejs

I have successfully configured Angular2+webpack along with NodeJs for the backend. Here is a basic setup overview: webpack.config.js: var webpack = require('webpack') var HtmlWebpackPlugin = require('html-webpack-plugin') var Extract ...

Ensuring Consistency in Array Lengths of Two Props in a Functional Component using TypeScript

Is there a way to ensure that two separate arrays passed as props to a functional component in React have the same length using TypeScript, triggering an error if they do not match? For instance, when utilizing this component within other components, it sh ...

Rotate object within HTML table

I have a simple data structure as shown below: [ { "ClientId": 512, "ProductId": 7779, "Date": "2019-01-01", "Quantity": 20.5, "Value": 10.5 }, { "ClientId": 512, "ProductId": ...