Next.js App vs. Pages Router - Which One is Better?

  Рет қаралды 49,640

Josh tried coding

Josh tried coding

11 ай бұрын

Since its release in May, the Next.js App Router is loved by many and criticized by others for not being production-ready. Which option makes more sense for your use case? Let's look at both the positives and negatives, allowing you to make a proper choice for your next project.
Discord: / discord
GitHub: github.com/joschan21

Пікірлер: 92
@dansurfrider
@dansurfrider 11 ай бұрын
You can read, so I'm not going to repeat it. *repeats it in reverse
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
yeah I noticed I literally just repeated it wtf
@richardkirigaya8254
@richardkirigaya8254 11 ай бұрын
Lmao
@real23lions
@real23lions 11 ай бұрын
😂😂
@kaviisuri9997
@kaviisuri9997 11 ай бұрын
You made me laugh out loud as soon as I clicked the video😂
@Taooflu
@Taooflu 11 ай бұрын
@@joshtriedcodinggood teachers repeat, it’s a good thing
@Imjoshnewton
@Imjoshnewton 11 ай бұрын
I think this is a natural progression that we go through in tech. New things are introduced to solve a problem or make something better, everyone is excited about it, lots of videos are made about it as it is a hot topic, then people realize it’s not a silver bullet that works for every situation. I’m sure like a lot of people I’m using the app router for side projects and even side hustles. However, the production apps I work on at work aren’t getting rewritten for the app directory any time soon.
@igrschmidt
@igrschmidt 11 ай бұрын
Great content as always! A video about all the caching possibilities using app router would be lovely.
@robertmorells9467
@robertmorells9467 11 ай бұрын
Hi Josh I think you are the most clear to understand teacher I have ever listened too, I feel I am absorbing the most important information from you than any other teacher out there, Because you are so up to date on the tech stack it’s crazy, please keep making these videos man you are one of the best out there :) P.S can’t wait to this new Open-Ai Functions get out there I would love to see how this new open-AI functions work and what the possibilities are as far as calling outside functions to interact with open-AI :)
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Really interested in those too. Thank you for the kind words man. Means a lot.
@bilbobeutlin3405
@bilbobeutlin3405 11 ай бұрын
I tried the app router with server components and i loved it, you can replace trpc pretty much with server components. It`s only confusing that there are no established patterns and best practices so you have to find something that works for you and hope its scales. But still super exicting to have so much new stuff to learn and explore!
@joshlansah
@joshlansah 11 ай бұрын
You are so consistent with your content. Thank you for providing this info for free.
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Appreciate ya dude
@gh0stcloud499
@gh0stcloud499 11 ай бұрын
One really nice thing about the T3 bootstrap with tRPC is that it give you a centralized endpoint that you can use to pipe additional context/middleware through. This is really nice for things like logging or authorization. I haven't found a nice way to do something similar with the app router. I might not have found it yet or it might simply be that nextjs is moving away from that paradigm (I guess the app router is more 'serverless' in that sense) . This plus type safety on requests are two things I think that are still missing from the app router. I hope Vercel look at how Nuxt handles their type safe requests. They do it in such an awesome way.
@TheViktors11
@TheViktors11 11 ай бұрын
Good point about other library support. Currently struggling to implement stripe with next 13 as it is. Planning a video on that anytime soon?
@muhammadusama7121
@muhammadusama7121 11 ай бұрын
Great video as always Josh. one thing I don't understand is. All web apps which I build have 90% api calls that have auth headers (user specific calls) in them and they are not cached by default. So does that mean I have to use the React cache function ? In docs they specifically mention that fetch data where you need it and due to deduping we should not be worried how many same calls we making. But when auth headers are present there is no deduping and have to rely on prop drilling which gets nasty. So is the React cache function the right way to do it?
@miro-hristov
@miro-hristov 11 ай бұрын
As of right now, the /app router is completely useless. It is nearly impossible to disable the cache and get new content when using . Even with revalidate = 0; or fetchCache = "force-no-store"; or prefetch={false} the data remains stale. You may get lucky if you refresh the page but that defeats the purpose of SPA. I'd love to see a minimal working example of Next 13 using and fetching new fresh data every time the link is clicked.
@ajinkyanarwade
@ajinkyanarwade 11 ай бұрын
Thank you Josh. Summary - 1. Routing pages directory uses client side routing while app uses server side rendering. Route map is not required to download in client for app directoy. Granular caching approach with app router. Dx and Ux is better. But pages is battle tested and used in production. 2. SUpport - Not ready yet. All page directory functionalities may not work. You will get more community support for page directory. 3. Performance Slower req per sconds parameter compared to pages directory. Switch incrementally to app routing from page routing for solving issues.
@anwar_thoughts2738
@anwar_thoughts2738 11 ай бұрын
Thank you for theses videos , i used app router in local env and my project was working fine wine but when I deployed it even before . When building it I had much errors from fetch to urls to revalidating errors that broke the building so I stopped and switched to pages and the project is fine and deployed now
@muhammedmaher6704
@muhammedmaher6704 11 ай бұрын
It's normal for me now to just click the like button even before I see the video, amazing work bro, keep it up. 💪
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Cheers dude appreciate it
@BeyondLegendary
@BeyondLegendary 11 ай бұрын
Look at that suble data fetching. The tasteful routing of it. Oh my god, it even has a caching mechanism.
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Oh my god are you the dude that keeps commenting the Paul Allen stuff hahahaha
@AnweshGangula
@AnweshGangula 11 ай бұрын
at 5:12, you mentioned D3 stack issues. can you add the link to the resource which talks about the issue?
@saralightbourne
@saralightbourne 11 ай бұрын
i've had a very weird issue with app router that forced me to go back to pages. there's loading.tsx fallback file which displays while page.tsx is being loaded and sent back to the client. i was writing client side filters which are synchronised with url query parameters so i used useRouter and .push method to change those parameters. but app's useRouter.push doesn't have {shallow: true} so every time a query parameter is changed, it requests page.tsx to load data again. and it's actually fine, no need to fetch data from client side with react-query or useSWR. but the problem is that it does not trigger loading.tsx so every time i selected new filters, the page was stuck for like 2 seconds while the new data is being rendered. i ended up rewriting that logic with pages router, react-query and getServerSide props for initial load of the content
@sahilaggarwal2004
@sahilaggarwal2004 11 ай бұрын
The app router is good, but the one thing that seems lacking to me with RSC is that you can't do client level caching for the pages that show user specific data, which is needed for a better offline experience in a PWA. Sticking with client components until that somehow magically becomes possible.
@rod6722
@rod6722 11 ай бұрын
Curious if you tried Remix, and if so how you think it compares to Next 13. It seems like some new Next features, like nested routing and server actions, were inspired by Remix.
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Oh yeah, remix had these features stable while Next.js just dropped them in beta. But haven't actually built any substantial app with Remix
@rijkvanwel
@rijkvanwel 11 ай бұрын
Great video, and having used the app router in a production app I support your final conclusion. It is really nice to work with, and the UX is far superior. We def do need better tooling around the cache though.
@jameshets6780
@jameshets6780 11 ай бұрын
The client side has better options for caching unless you want to pay more for server (Vercel). It's puzzling why every Nextjs feature relies on the server.
@NOBODYxx09
@NOBODYxx09 11 ай бұрын
@@jameshets6780 devices are so much advanced these days i do think some things like caching should be handled on the devices right?
@greendsnow
@greendsnow 11 ай бұрын
I jumped to Astro and I'm happy about it.
@HungNguyen-tl9kg
@HungNguyen-tl9kg 11 ай бұрын
I got into this message when try to use app dir & pages dir together. "Warning: Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported." what does it really mean?
@qwerty-or1yg
@qwerty-or1yg 4 ай бұрын
How would you go about implementing a sidebar layout in /blog/id pages but all other pages would have a root layout using nextjs app router
@rockNbrain
@rockNbrain 11 ай бұрын
Great job Josh 🎉 tks
@RaghuprasaadIyer
@RaghuprasaadIyer 11 ай бұрын
can you make a video on astro vs qwik and show perfformance comparison and which one do you prefer, since both of them are more performant than nextjs pages and app
@mogipls
@mogipls 11 ай бұрын
Great, I was actually literally about to Google this, how timely
@shahariarniloy8935
@shahariarniloy8935 11 ай бұрын
To me app router is more declarative than page router. it has certain rules/convention to follow and has lesser control to do conditional stuff. rather page router is more imperative and devs has much more control over whole app.
@MDKhan-ww5tp
@MDKhan-ww5tp 11 ай бұрын
Love you videos but can you please make a video on your vscode setup
@tomirodriguez7195
@tomirodriguez7195 11 ай бұрын
I love how app router works and all the idea behind to move all client stuff to the server. That been said, I still think the support from libraries is a BIG trade off that I'm not sure I want to pay. The beauty about all this, is that both con live together, so you could be using app router and page router as you mention in your video, without any problem :)
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Exactly. People have speculated the pages router might be completely removed in Next.js 14 in the future, but judging by how slow corporate adoption for new tech is I am convinced incremental adoption like this will be available for a looong time
@mohitcodeswell
@mohitcodeswell 11 ай бұрын
Hey Josh, please make a complete tutorial on frontend authentication on react (or next). To understand the complete flow with all possible user interferences.
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Aye good idea, could highlight both next-auth and an external service like clerk for that
@dennisgroen4932
@dennisgroen4932 11 ай бұрын
@@joshtriedcoding In addition I would love to see how you would solve the problem for local dev with next auth, like how you can switch between users without having to use lets say a google auth. This would be helpful if you want to develop when being offline
@real23lions
@real23lions 11 ай бұрын
@@joshtriedcodingthat would be useful. I’m using Clerk. Would love to see another point of view
@DestinoDello
@DestinoDello 11 ай бұрын
Clerk
@mohitcodeswell
@mohitcodeswell 11 ай бұрын
@@real23lions I've never used clerk. Could you brief me about that ?
@questionyourbeliefs
@questionyourbeliefs 9 ай бұрын
When you say you can switch back to pages, are you saying that you can have a pages and app router alongside each other? Did not know this was possible!
@user-py2le2gx9b
@user-py2le2gx9b 10 ай бұрын
even use export const dynamic or revalidate 0 , the page still cache, how to fix em ?
@AsemAmr19
@AsemAmr19 11 ай бұрын
the App direcoty router is awesome with it's reserved compnent and I really like it, But one thing i have issue with it is the Page Transition when I implement the Page Transition with framer motion library it doesn't work for me mybe the machenism of page transiton in framer motion developt according to the page rounter only. I don't know
@toonhouse4286
@toonhouse4286 11 ай бұрын
I have also faced a problem with uploading files using the app router. I spent two days debugging, but unfortunately, I couldn't find a solution. Currently, I am using both pages and the app router to address the issue. 😒
@BlobBlobkins
@BlobBlobkins 11 ай бұрын
Would like to see a video about caching that you mentioned.
@footballforlife09
@footballforlife09 4 ай бұрын
What about transitioning from pages router to app router, is that upgrade possible?
@user-nq7di4og3z
@user-nq7di4og3z 11 ай бұрын
app routers is hard for me to use and understand, but that doesn't stop me from looking forward to the new way of routing!--.--
@arcsenco.3774
@arcsenco.3774 11 ай бұрын
Seems like App Router's deployment was rushed. Some of the new routing changes could've been implemented incrementally so that there wasn't such a big shock to the ecosystem. Now it seem s like the react ecosystem is trying to adjust to this major change. I enjoy some of the new changes though and they've done a good job but for simpler applications the old method seems like the way to go
@jakelanning1535
@jakelanning1535 11 ай бұрын
I have tried using the app router hosting on aws. I'm having problems accessing the cookies in the server component. Its extremely frustrating, as it works fine on vercel and my local, but not on the aws deployment. It's very weird, the site works on first load, but on subsequent refreshes I get 500s on pages where i try to access the cookies (have tested using both headers() and cookies() - same thing). The only console error is 'A client side exception occured'. I wish I could figure out another way to look into the logging. It seems like the first load is properly server rendered, but the refresh is trying to render my server component on the client, causing an error. Either way, the problem doesn't exist with getServerSideProps, so I'll be using that. I really hope AWS fixes this, I would love to delete the pages directory. It's a new project, I don't want to start using pages on the side, knowing that the app is available.
@zmorphy
@zmorphy 9 ай бұрын
Did you solve the problem or did you end up switching to page?
@jakelanning1535
@jakelanning1535 9 ай бұрын
Switched to svelte lol. Trying to play with cookies in an app that can be both server side and client side rendered is a recipe for a bad time.@@zmorphy
@user-wr3qq1oc7o
@user-wr3qq1oc7o 6 ай бұрын
i have very big problem in the one of my project in app router and this is that i cant catch the complete URL or after hash(#) in URL *in server component* or *server side* and that why i want drop app router. as you know we can use (Param) for get just first section of dynamic URL or route and use (searchParam) for catch query parameter after that but i cant catch *hash* after dynamic router. could you plz pin my problem its very serious.
@developerpranav
@developerpranav 11 ай бұрын
Hey your discord server link isnt working
@user-sm3rx2uw7r
@user-sm3rx2uw7r 11 ай бұрын
acan u explain how the cookie Pop up wotks and how to store them in a DB
@realdaly
@realdaly 11 ай бұрын
tbh I didn't know that u can use the "pages" and "app" at the same project!
@gunman479
@gunman479 11 ай бұрын
I've recently experienced issues with the App router and API routes. I can't seem to get DELETE requests working. I get TypeError: Response body object should not be disturbed or locked.
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
Interesting that shouldn't happen
@huzaifac137
@huzaifac137 11 ай бұрын
I also struggled with the delete requests while passing headers and using them .
@nat_pinnock
@nat_pinnock 11 ай бұрын
I think there is an open GitHub issue on this. I had to roll back to 13.2 (if I remember correctly) to get delete requests to work
@gunman479
@gunman479 11 ай бұрын
Confirmed working in 13.2! I guess 13.4.6 isn't quite ready yet.
@NenadKaevik
@NenadKaevik 2 ай бұрын
Man i just finished a whole app in react and i totally forgot about SEO so now im banging my head to switch to next with app router -_-
@Dev-Siri
@Dev-Siri 11 ай бұрын
Next 13: Think static, think fast, Think Caching, DO dynamic
@kdstudiogames3602
@kdstudiogames3602 11 ай бұрын
Can we use app router and page router both in same project?
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
oh yeah
@kdstudiogames3602
@kdstudiogames3602 11 ай бұрын
@@joshtriedcoding brother, can I get your WhatsApp number?
@lehaiquantb
@lehaiquantb 11 ай бұрын
@@joshtriedcoding Im starting with new project, but confusing. please make a video showing how to do that. Thanks
@khaledsanny4817
@khaledsanny4817 11 ай бұрын
Website became so complex to build… i like app router but page router is better for me … and I prefer how NuxtJS handle renderings even more
@codinginflow
@codinginflow 11 ай бұрын
Fun fact: I created this Reddit thread: 3:09. One or two points were a misunderstanding by me tho. But I've also found some other problems meanwhile.
@MrManafon
@MrManafon 11 ай бұрын
T3 works just fine with app router, its just not the default
@Metruzanca
@Metruzanca 8 ай бұрын
0:05 - jesus fucking christ, love me some good accurate titles.
@BensLifeTips
@BensLifeTips 8 ай бұрын
No CSS-in-JS!!! WTF were they thinking?!?!? This cuts out so much of the dev community who love Styled-Components, Emotion, etc.
@JohnnySalami-jo4jh
@JohnnySalami-jo4jh 9 ай бұрын
It seems that the new App Router doesn't allow for shallow routing just yet? Anyone have any insight on this?
@sigmamale7914
@sigmamale7914 11 ай бұрын
pls build a video / Day in a life of 'Josh" so we can see , bc u work hard too much
@sigmamale7914
@sigmamale7914 11 ай бұрын
please teach advanced next-js13.4 all features all in one video
@joshtriedcoding
@joshtriedcoding 11 ай бұрын
that would be a long ass video
@samislam2746
@samislam2746 4 ай бұрын
Vercel is pushing react into the edge, and literally this is destroying the simplicity of what react used to be.
@diego0ji
@diego0ji 11 ай бұрын
Pages!!!!
@xxXAsuraXxx
@xxXAsuraXxx 9 ай бұрын
The latest is always the best, until they are actaully stable
@meowhib
@meowhib 11 ай бұрын
Bruh I started learning it 3 days ago don't do this to me
@kakun7238
@kakun7238 11 ай бұрын
its fine but i would suggest to learn the pages router first
@codedusting
@codedusting 11 ай бұрын
This is hard to follow. Everything you said, if followed by practical example, would have helped better.
@user-ff3wc9fm5u
@user-ff3wc9fm5u 11 ай бұрын
traveler
10 common mistakes with the Next.js App Router
20:37
Vercel
Рет қаралды 175 М.
Next.js App Router REVIEW (Six Months In Prod)
16:10
Theo - t3․gg
Рет қаралды 59 М.
Eccentric clown jack #short #angel #clown
00:33
Super Beauty team
Рет қаралды 24 МЛН
Como ela fez isso? 😲
00:12
Los Wagners
Рет қаралды 29 МЛН
Would you like a delicious big mooncake? #shorts#Mooncake #China #Chinesefood
00:30
Jump Game - Greedy - Leetcode 55
16:28
NeetCode
Рет қаралды 206 М.
Next.js App vs Pages Router - Which One is Better?
9:57
Ankita Kulkarni
Рет қаралды 1,8 М.
How to integrate device fingerprint with web application
0:23
Next.js isn't React
17:11
JavaScript Mastery
Рет қаралды 193 М.
What are my thoughts on next.js app router vs pages router
11:04
Web Dev Cody
Рет қаралды 21 М.
Pages Router vs App Router in Next.js - Key Differences
12:24
Coding Reflections
Рет қаралды 6 М.
The Worst Thing About Next.js 13
6:37
Josh tried coding
Рет қаралды 34 М.
5 New AI Tools You Should Try
9:18
Skill Leap AI
Рет қаралды 10 М.
Next js 15 is Here… New Changes Again?!
8:13
JavaScript Mastery
Рет қаралды 89 М.
iPhone 15 Pro vs Samsung s24🤣 #shorts
0:10
Tech Tonics
Рет қаралды 9 МЛН
What’s your charging level??
0:14
Татьяна Дука
Рет қаралды 7 МЛН
ПК с Авито за 3000р
0:58
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,5 МЛН