News for hackers. Stuff that matters.
Re:Next.js App Router Update by warent on Thursday June 22, 2023 @08:35PM (#36441198)
Except getServerSideProps is no longer used in Next 13 and actually you have no simple access to the request object anymore. Have to write middleware for everything, it is extremely frustrating
Re:Next.js App Router Update by xyzzy4747 on Thursday June 22, 2023 @08:46PM (#36441283)
Ah, I see. That’s very annoying.
Re:Next.js App Router Update by williamstein on Thursday June 22, 2023 @08:47PM (#36441291)
To clarify -- using getServerSideProps works for routes defined in the pages/ directory in Next 13, but not for routes defined in the app/ directory. Both pages and app are still fully supported in Next 13. See https://nextjs.org/docs/app/building-your-application/routin...
Re:Next.js App Router Update by charcircuit on Thursday June 22, 2023 @09:11PM (#36441502)
Yes, I tried making a middleware for auth, but it just was not working for me. I think I had trouble passing along information to the actual page or something. I also was unable to have my login page handle authentication to set the cookie so I had to do go and make an API for it. I eventually cut my losses and gave up since it felt like my app was going against the grain.
Re:Next.js App Router Update by joshgermon on Thursday June 22, 2023 @11:47PM (#36442544)
Yeah which honestly I don't mind the middleware approach for authentication although the route matching is pretty bad for fine grain control.

However another thing is the middleware is all through the edge runtime. So things like regular postgres drivers don't work (although I did hear that Cloudflare workers added TCP so maybe that's coming).

I will say Planetscale and the hottest db as a service platforms all seem to have an edge adapter to allow for this but your SOL otherwise.

Re:Next.js App Router Update by phryneas on Friday June 23, 2023 @04:14AM (#36444157)
You can just call the `cookies()` or `headers()` function in every server component in the app router?
Re:Next.js App Router Update by dbbk on Friday June 23, 2023 @08:24AM (#36445867)
> Except getServerSideProps is no longer used in Next 13

Yes it is?