What are the reasons for the default router in Next Js not functioning properly?

My default router is not functioning properly even though I have used the correct folder structure in version 13.5.4 of Next Js.

I created a new project using the command npx create-next-app@latest project name. Within the App folder, I created a folder called user. Inside the user folder, I created an about.js file. However, when I try to access the URL (http://localhost:3000/user), it shows a 404 page. I can't figure out why this is happening.

View Folder Structure

See 404 Error Page

Answer №1

When you opt for the "app folder" in Next.js, make sure your pages are named as "page.js" (or "page.jsx" or "page.tsx")

For example, if you wish to go to the user page at localhost:3000/user, organize your directories like this:

app/
  user/
    page.js

See more details here: https://nextjs.org/docs/app/api-reference/functions/use-search-params

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

Tips for creating consistent spacing between elements using Tailwind CSS version 3

I am currently utilizing Tailwind CSS in conjunction with next.js for my project. I have a total of 8 images, each varying in size, and my goal is to display 4 images per row on medium and large devices, while displaying 2 images per row on small devices. ...

Having trouble retrieving data from Express server to React app

Trying to retrieve data from the server in order to display some articles has been a bit tricky. Although Postman successfully returns an array of objects and http://localhost:5000/articles displays them perfectly, there seems to be a problem when fetching ...

Trouble arises when the properties of this.props are supposed to exist, yet they are not

Wow, what a name. I am struggling to come up with a better title given my current state. The problem at hand is as follows: When using React, I set the state to null during componentWillMount. This state is then updated after data is fetched from a serve ...

Abruptly shut down: Stripe/Apple Pay

We have a React-based web application that is set up to accept payments through Stripe integration. However, we are facing an issue where the Apply Pay option popup closes abruptly before users can complete the transaction. We have ensured that the domai ...

Unable to retrieve the body from an HTTP POST request in NextJS

Currently stuck and seeking assistance to uncover the missing piece that is preventing progress. The goal is to obtain access to the body of a POST request, as demonstrated on this page from Next.js: https://nextjs.org/docs/pages/building-your-application ...

What is the best way to ensure that a Material UI transition component fully occupies the space of its parent component?

I've been experimenting with a Material UI transition component in an attempt to make it completely fill its parent container. So far, I've achieved some success by setting the width and height to 100% and applying a Y-axis translation for the co ...

Nextjs doesn't render the default JSX for a boolean state on the server side

I am working on a basic nextjs page to display a Post. Everything is functioning smoothly and nextjs is rendering the entire page server side for optimal SEO performance. However, I have decided to introduce an edit mode using a boolean state: const PostPa ...

What is the best method for accessing a store in Next.js with Redux Toolkit?

Currently, I am working on incorporating integration testing for my application using Jest. To achieve this, I need to render components in order to interact with various queries. However, in order to render a component, it must be wrapped in a Provider to ...

Secure your website with the latest JWT cookie security measures

After storing a JWT with an expiry date set 30 days ahead, the question arises - is it secure to store this JWT in a cookie? The aim is for the token to persist beyond a single session, much like the "Keep me logged in" feature found on some websites. Se ...

Creating a personalized event using typescript

I need help with properly defining the schema for an EventObject, specifically what should be included within the "extendedProps" key. Currently, my schema looks like this: interface ICustomExtendedProps { privateNote?: string; publicNote?: string; ...

Forgetting a crucial step in the process of updating a static ReactJS website on Google Cloud Platform

Replacing the contents in the bucket associated with an app may not update the app as expected. I recently deployed a site where I created a bucket, a directory, and deployed a React app using commands like: gsutil rsync -r gs://bucket-name ./app-name T ...

Troubleshooting MUI Grid's placement dilemma

Is it possible to make the card appear in the middle of the MUI grid after adding only one element, and then follow the grid system? Currently, when I add a single element, it appears in the left-most corner. Here is my code: import React from 'react& ...

What does {``} denote in react-native programming?

During my participation in a collaborative project, I noticed that there is a significant amount of {' '} being used. For instance: <Text> {' '} {constant.Messages.PointText.hey} {this._user.first_name || this._user ...

Running a Next.js application on Google Firebase Functions may lead to encountering a 304 error message with Cross-Origin

Being new to Firebase and lacking experience, I recently deployed a simple SSR Next.js app with Firebase Functions. However, I encountered an issue where everything except the HTML is blocked on the app. The browser console displayed the following errors: ...

The functionality of Router.push() seems to vary depending on the timing

I'm attempting to utilize router.push() to modify the URL when the Search button is clicked. However, I've encountered a situation where this function only works sporadically. Ideally, after clicking the button, the user should be directed to the ...

Leaflet GeoJSON Turf library encountered an error: Invalid coordinates for LatLng object: (undefined, undefined)

After setting the return to null for the component and condition in question to check the data being returned, I thoroughly examined the coordinates arrays without finding any issues. The data comes in as an array of geometry collections containing linest ...

Preventing page reload in Supabase with NextJS when the website loses focus and regains it

I am working with the structure in _app.js of my Next.js app. // _app.js // import ... import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs' import { SessionContextProvider } from '@supabase/auth-helpers-react' // ...

The term "Movie" is not compatible as a JSX component

Currently working on a movie app project but encountering issues with handling arguments and displaying them properly using TypeScript. The challenge lies in trying to map the movie object, display them individually on the homepage, and showcase all the re ...

Retrieve information from a URL to transmit to a different page in NextJS using Typescript and AppRouter

I'm struggling with transitioning from the Home page to the Detail page. I've successfully passed data to the URL from the Home screen, but I'm having trouble accessing it in the Detail screen. I'm working with NextJS ver 13, using Type ...

Building a personalized React component poses challenges when working with MUI REACT interfaces

I am looking to develop a unique component that will display two different elements, an icon, and a title. However, I seem to be encountering errors from TypeScript regarding the declaration of my interface. The error message reads: Property 'map&apos ...