Questions tagged [nextjs13]

1277 questions
33
votes
5 answers

NextJS 13 folder structure best practice

I'm learning to use NextJS and I'm using the latest version with App Router, I'm currently stuck on how to do routing, such as where to put the register and login pages, and its' folder structure in general, where I put components and how to group…
Dead
  • 361
  • 1
  • 3
  • 6
16
votes
2 answers

How to access request body in nextjs 13.2 route handler

I was trying to send a post request to my api. However trying to access the request body in the route handler causes the error below: Code: export async function POST(request: Request) { const postBody: postProps = JSON.parse(request.body) // …
lool
  • 345
  • 1
  • 6
  • 11
14
votes
2 answers

Does 'use client' in Next.js 13 root layout make whole routes client component?

I was trying Nextjs 13 with Next-auth and Apollo Client. For that we wrap the root layout with the providers but we also need 'use client' to be specified. I have no problem with the libraries. But what is confusing to me is that nextjs 13 app dir…
12
votes
3 answers

Not-found page does not work in next.js 13

This is the sturcure of my next.js project. And my 404.js page is : 'use client'; export default function NotFound() { return (

Not Found

); } when I enter the wrong route it does not work…
AR Second
  • 582
  • 1
  • 6
  • 25
11
votes
10 answers

Adding Favicon to NextJs 13 Beta (No pages folder)

I have an issue with the new Next.js 13 beta. They removed head.js files and now (as it is written in doc) I have to use metadata in layout.ts. My favicon has name favicon.png. How do i specify it here: export const metadata = { title: 'Create Next…
Nazar Duma
  • 127
  • 1
  • 1
  • 9
11
votes
3 answers

How do I use next auth getServerSession in next js 13 beta server component in app directory

I'm using next auth v4 with next js 13 beta with server component, and everything works fine. But I have a situation where I will need to know the logged user id, since I'm using next auth, I have access to the session, I can use useSession() but…
Shakib Hasan
  • 231
  • 1
  • 1
  • 8
11
votes
2 answers

Next.js 13 - Have different shared layouts

I now want to upgrade to Next 13. I have different navbars on my portfolio. How can I use a different navbar for the /about and /skills route than the home page and /contact route? I thought you could now create different subfolders within the app…
iAmWhy
  • 327
  • 2
  • 13
9
votes
2 answers

Can't Access Values from Next Server Actions | Next.js 13.4

I'm curious how we'd be able to go about accessing returned values from Next.js 13's alpha release of server actions. Here's the documentation from the Next team for reference. Let's say I have the following example server action to perform input…
9
votes
4 answers

Pass props to page.jsx child from root layout (next.js 13)

How do you pass props to the the page.jsx of layout? (NEXT 13) //app/blog/layout.jsx export default function RootLayout({ children }) { return (
{/*How do I pass any props from this root layout…
Vivaan Kumar
  • 457
  • 3
  • 4
  • 9
8
votes
4 answers

Adding a tag to using Next.js>13.3 with appDir enabled

The documentation for using appDir on Next.js 13.4 states the following: Step 3: Migrating next/head In the pages directory, the next/head React component is used to manage HTML elements such as title and meta. In the app directory, next/head is…
villasv
  • 6,304
  • 2
  • 44
  • 78
7
votes
2 answers

Nextjs 13 is insanely slow in dev environment

I will be very brief: I recently switched to Nextjs 13 and I noticed it's insanely slow when I run my app on localhost via npm run dev Pages even take 10 seconds and sometimes even longer to load, how it is possible? To all who use Nextjs: do you…
DaMatt91
  • 544
  • 1
  • 7
  • 18
7
votes
2 answers

Does Axios can be used in new next.js 13 instead of exteded next fetch api version?

Hey guys, can I use axios with next.js 13 and still get the same results of their extended fetch api version with cache and revalidate configs ?? Is axios going to this web-standard thing direction ?? I realy love axios.intereceptors…
7
votes
2 answers

how to render async page components as a child in next.js?

I am using the next.js new functionality to render content using SSR, I am making component async as docs says. So this is my simple page component export default async function Home() { const res = await…
Visrut
  • 360
  • 4
  • 14
7
votes
2 answers

How to return API response status in NextJS13?

Right now am using different ways to return API HTTP status in my NextJS-13 but nothing seems to be working for me. Note: I am using Typescript in my project. Here is my code with static 200 API response and am sending API status in body: type…
Wali Amed
  • 73
  • 1
  • 5
7
votes
4 answers

How to get route pathname inside nextjs 13 app using the latest app directory? "Server Side"

I'm using the experimental appDir in Next.js 13, and want to get the URL path of the request. I need this info to set the searchparams before I do the redirection. I want to get the request path on the server side. There is a question with similar…
p2hari
  • 494
  • 6
  • 16
1
2 3
84 85