Next.js App Router Update
nextjs.org
nextjs.org
Perhaps it's because I'm leaning my focus into business now. But it's so much faster to build landing pages using old stuff like wordpress. Sure it has its downsides but it brings so much to the table. And there's so much plugins to do everything you need. Caching? 1 click install and done. SEO? Easy. Admin panel? Built in.
And say you're building a SaaS. The internal app could be whatever you want it to be. Since it's internal, there's no need to worry about SEO. At that point, I'd rather use SPA to avoid all the issues Next.js brings.
Though that's not to say Next.js is all bad. I just think it's not there yet and it may be a while until it becomes stable.
I can understand the performance argument but most of that is being worked on and the next team has already shipped lots of improvements in the past. But maybe the things I worked on haven’t reached a scale yet where these things become a bottleneck.
I would be happy to talk about NextJS and LLM's and AI if you're up for it.
Leaving my email on my profile for some days.
It definitely could be better. They're making a pathing mess with eg. parallel routes but it's not /that/ big of a deal all in all. The problem being that when you rely on file paths for routing, you then end up having to build in all kinds of hacks and conventions in the file paths, which are just... not designed for that, they're just keys to files.
But the core of the structure and architecture is sound.
https://nextjs.org/docs/app/building-your-application/data-f...
VPS is slightly lower level which gives you a lot more control: integrate with your existing Node.js backend (use any backend framework you want), deploy anywhere, use any React alternative (Solid, Preact, ...) and any data fetching tool (e.g. Relay can't really be used with Next.js).
The flip side is that you've to write a little bit more glue code. Although this will be alleviated by a lot with projects such as Bati[0], Stem[1], and vike-react (see Vike Rebranding[2]).
VPS also cares a ton about details, such as hooks for full control over i18n (use any i18n strategy you want), better Base URL support (VPS supports setting a different base for your server and your CDN), automatic deploy synchronisation, domain-driven file structure, polished and helpful error messages (especially the next upcoming release), ...
Detailed comparison with Next.js: [3].
If you run into any blocker then it's quickly fixed (or at least a workaround is proposed).
It supports not only SSR and pre-rendering, but also SPA in case you don't need SSR. It's going to support RSC but doesn't yet (RSC isn't ready for production).
Because it's lower level and because it's decoupled from React everything is designed in an agnostic way and with meticulous care. In other words: vite-plugin-ssr is becoming a robust foundation. There are breaking changes coming for the v1 release but beyond that chances are that there won't be any breaking changes for years in a row.
In a nutshell: vite-plugin-ssr takes care of the frontend and only the frontend. You keep control over your architecture. (Whereas frameworks tend to put themselves right in the middle of your architecture restricting you in fundamental ways.)
Last but not least: it's powered by Vite which means blazing fast HMR.
Why not use simple .htaccess to map URLs to folders/files like always? Then, if you simply must use a JS framework like React...run it on those corresponding pages. Why use yet another framework (Next) on top of this to handle such a simple thing?
Some other neat bonuses are:
- Page transitions still use client side routing so it still feels fast like a SPA, and it automatically preserves state on your outer layouts during page changes.
- And something I find mind blowingly impressive is you can refresh the server rendered HTML at any point while the user is on the page while still preserving all of their client side state and scroll position etc. A simple call to `router.refresh()` is all you need to do that, something that would have taken a good amount of API code and shoving stuff into some state management library etc to do before.
While Apache was wildly popular htaccess files and cgi/fcgi adapters for php, Perl and such were everywhere. These days they’ve fallen out of favor and every cloud provider has their own version of this that you can use.
But let’s not pretend this is the way things have always been done, in my career pre-cloud I’ve worked with Apache and nginx, but also with Java servers (tomcat etc), phusion, IIS and occasionally custom app servers that would speak http.
I ended up migrating to Remix and my application was easy to build how I wanted with cookies. Next.js API for working with cookies wasn't that good either.
Unfortunately, this update did not include anything to address this. Next.js seems fine to use if you are making a landing page or some site which does not require authentication, but I wouldn't use it for anything complex.
It’s slightly annoying though since you can’t use both getServerSideProps and getStaticProps on the same page.
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.
Yes it is?
If you have to re-engineer all your code to avoid content shift, why bother using a mega-framework like Next in the first place? Also the point of SSR and hydration is to improve performance and page loads, if you have a ton of work to do again on the client that's very small actual performance gains, but that's not so much of a surprise considering Next is one of the heaviest frameworks out there (in bundle size)
I'd also like to mention that I regret my uncharitable phrasing in my original comment "…the most ungooglable and generic name they could have chosen…". While I do think more specific names might have helped in some ways, I can appreciate the difficulty in coming up with names for this kind of thing.
I used the CSS toolkit called Less and that name took the worst out of each hand. That was just terrible re: searching for things.
I tried to use the new app router, but it felt infuriatingly opaque to me, so I just went back to pages. Fortunately you can use the newest nextJS v13 and still have access to the old Pages system.
Yet it'll replace pages router in the near future, seems like a risky situation to be in as a pages router fan.
The folder structure is also very 'angular' and opinionated. It has started to disappoint me that Next.js is becoming too opinionated as time goes on and the 'new' things are nothing but worse in performance and DX. The pages folder structure was awesome, easy to understand and manage. Now it's all just 10s of page.tsx files in your editor.
I used to love Next.js, I still do but I'm not sure if I will in the near future.
However, with adopting the App Router there is a big looming question - what happens with frontend state/query management libraries like react-query/trpc?
So far, I’ve seen unergonomic solutions that require the developer to manually hydrate the frontend. Hopefully, over the next few months we discover a solution that “just works”, so we can widely adopt RSC.
What's not clear to me is where do the providers go (ReduxProvider, ReactQueryProvider etc)?
Can they be instantiated up tree in a server component somewhere? And if that's the case, what data do they hold when on the server and what happens a client component tries to interact with the provider?
Or should I render as much as possible via RSC and put the providers in the first client component in the tree?
I've been trying to keep tabs on the GitHub issues and Discord that discuss this, but I have to admit, it's a bit over my head. The best resource I've found so far to understand how libraries are adapting is from Apollo's RFC here: https://github.com/apollographql/apollo-client-nextjs/blob/p...
Also the new app routers are very confusing. There are concepts of a layout, template, page, etc. While it's nice to have server rendering at this level, it's difficult to understand what is bubbling which direction, and when to use a layout vs a template. Sometimes after building something one way (eg using layout), you realize you actually need to build it using the other in order for specific features to work.
Old Next was great and simple- new Next has become increasingly frustrating and not so easy to adopt.
Where are you landing into the docs from, Google? We try to add version history notes at the bottom of docs pages, but maybe we should place these at the top. Open to feedback.
I don't want to trawl through what is essentially a changelog, I want to browse/search the docs for the version I am using.
Having them separate was better for documentation satisfaction.
I’ve tried to make it work for SPA development but it doesn’t work in that scenario well as all recent data fetching libs were using hooks which you can’t use in async functions. Seem like people aren’t sure how to best solve it now.
Remix is always touted as the alternative but it seems like a whole new approach to learn and it's own strong opinions.
I've been using Next for 3+ years but I don't feel confident to start a new project today. Do I go to the dying page router? Or trail blaze with the app router with all the teething issues and issues everyone's encountering (myself included).
I'm not convinced the server components experiment is going to work in the end. They might even end up abandoning it.
Thank you so much for this! I recently gave up on trying to learn Next.js because the tutorial and the vast majority of the documentation only covered the "old" Pages Router way of doing things.
1. Server components have poor support for certain (non tailwind) css solutions. We had hoped to use vanilla-extract as its syntacticly similar to other css-in-js solutions, but ran into issues with HMR completely falling apart locally if the page contained a NextImage. We ended up falling back to good ol’ fashion sass modules.
2. As some other commenters mentioned googling for support somewhat consistently lands you on the opposite routers docs and while it’s somewhat obvious to tell where you are its still missable if you are moving quick.
All that to say I’m personally, _sorta_ burnt on Next and have found a ton of joy using svelte + sveltekit for my personal/hobby projects.
(eg: heroku and render)
Not 100% sure if this is what is causing that on Vercel, but seems fair to me for free tiers?
And there isn’t a way to signify loading as those events on the router are gone.
I've been coding in React for 6 years and in Next for 3 years. My next project will be in Vue.
Javascript isn't sufficient... to React/Vue aren't sufficient... to Next/Nuxt are <insufficient? too complicated?>
Why didn't the bandwagon just end at the first layer of frameworks?
Because I'm fed up with all the unnecessary complexity, and I want to try Vue because it looks a lot less complex, and I've already had a positive experience in the ecosystem with Vite and Vitest.
You could keep using the react you've always liked?
You're right that Vue will be a novelty - that's what I'm saying: React has jumped the shark to the point that it's now worth trying something for its novelty, because it just might be better.
This tends to reduce certain classes of bugs like side effects from unexpected re-renders and performance issues like over rendering.
The thing with React and Next is that it's great if your team is relatively homogeneous in terms of skill and experience or you have strong systems in place to enforce practices. However, the render cycle of React and the provider pattern is prone to bugginess otherwise. A firsthand example is Algolia's React components. Look at the GH issues. We ran into tons of issues related to unexpected redraws.
Like having data corruption issues from GET requests.
---
I prefer explicit, but if implicit fine grained reactivity is the sole point of concern, you might be interested in React+MobX.
MobX and Valtio create an illusion of fine-grained reactivity but do not change the underlying render cycle of React itself.
Seems too a bit too beta atm.
Nested folders routing is a mess. Overall the nextjs routing is a mess. It's vendor lockin. How can i use next router outside of nextjs ?
There's no progressive enhancement builtin. Your static html will always need to deliver that next-runtime. Why ? There must be something wrong at the foundation level.
There's no official guidance on how to do the Authentication. In NodeJS, we do have PassportJS!
I love RSC, React Streaming, React Suspense, but the way NextJS use it seems like vendor lockin (Vercel).
Want to use Babel, modify webpack with SWC compiler ? It's just confusing.
No more NextJS until they fixed the foundation.
I find the “new” way to write Next apps incredibly confusing. Everything is now a mix of server and client and there’s so much rendering complexity. Im sure for big ambitious companies this focus on performance is great, but I find that it greatly compromises developer experience.
I’ve also found the piecemeal transition to the new app router pretty challenging as I’ve had to feel around to find the issues (of which there have been a few)
That said, Vercel makes deployment so easy so I’ll probably stick around a while longer to see if things get ironed out.
RedwoodJS
Remix
If I had to compare them, I would label Redwood as more of an "emberjs" type feel, very corpo, angular-js, "enterprise". Remix is more loose and new, fresh ideas that other frameworks have since attempted to copy.
Pick your poison.
Also, they recently introduced a Node compatibility feature that supports _most_ modules. You can import directly from NPM using the npm: specifier, or import (almost) all of the builtin Node APIs using the standard node: specifier. Since recent versions (1.30+) of Deno are bundled with whats essentially a Node clone, and since its all packaged as a ~32MB executable... I've found myself just using Deno for everything lately. So far its been able to handle all of the projects I used to run with Node.
Check out their docs: https://deno.land/manual
We have seen it all before and will continue to see it again.
> Any successful project will start by doing one thing, well, but end up doing many things, poorly.
Apologies that you've ran into a few issues trying things out. We're working hard to patch up some of these. If you have any specifics, please let me know and we can look into them.
On the contrary, the performance with the new method is even worse.