Are Metaframeworks Like NextJS The Future Of React & co?
18 minAudio
Metaframeworks like NextJS, Remix or Nuxt have become very popular over the last ~2 years. Indeed, React is now recommending NextJS as the best way of getting started with React. So will those metaframeworks replace "vanilla React" etc?
Audio and video play straight from the show's own hosting. PodSubs stores and serves no media.
Transcript
From the show. Tap a time to play from there.
Are meta frameworks like Next, Remix, AnalogJS or Nuxt, are those the future of web development? Should every web developer use those meta frameworks and learn how to build full stack applications with them? Well, I think if you are working with React or Angular or Vue, yes, you should definitely learn those meta frameworks because I believe they are the future of
React and Angular and so on. Well, especially for React and I'll get back to that in a second. But I believe they are the future of those frontend libraries and frameworks because they solve an important problem. When we build a website, a web application, we typically don't just need a frontend, we also need a backend and that of course has always been the case and we were able to build websites and
web applications that have both a frontend and a backend without those meta frameworks as well, right? I mean, you could simply build a frontend single page application, for example, with React and then connect it, so to say, to a backend that's built with Node and Express. So you could build such a backend API, typically a REST API, but could also be a GraphQL API and then you could send
requests to that backend from inside the frontend application, for example, with help of React Query, which is a popular library for doing that, or simply by using the Fetch API inside of UseEffect, for example, or in Angular by using Angular's built-in HTTP client. And then you could fetch data from the backend or send data to that backend and update the frontend UI accordingly to, for example, show that data or if data
was sent to show a success message. We don't need those meta frameworks like Next for that. That's absolutely not the case. But those meta frameworks like Next or Remix and so on can make building complex full-stack applications, so where you have both the frontend and the backend, simply a bit easier and solve certain problems. And that's their huge advantage. And they do make that easier and solve
certain problems by giving you a seamless integration, by blending frontend and backend code with each other, so to say. That can also lead to new problems because as a developer, you should absolutely understand where exactly the border is between backend and frontend code so that you make sure that the wrong code doesn't end up on the wrong end. But mostly, it can help get rid of certain
problems or simply make it a bit easier to write complex applications. Because, for example, when you're working with Next.js, but also with Remix and so on, you can effectively fetch data from right inside your React component, for example. Or with Remix, you would do it in a separate function which is placed close to your component typically, though. You could fetch data from there and then render your HTML code with help
of React that's already including that fetched data. And all that would happen on the server and the advantage of that would be that the user, the client, receives the finished web page. So it gets back a response from the server that already contains all the markup with all the content that's needed for the page that was requested. And that, for example, is great for search engine optimization because those
search engine crawlers then also see all the content and see the finished page. Whereas with traditional single page applications, that page that's coming back from a server would typically be empty and contain no content because that content would have been fetched from inside the browser with help of client-side JavaScript code. And whilst to the user that might not make that much of a difference because
fetching that data often is pretty quick, it still can because they might temporarily see some loading spinner or some progress bar whilst they're waiting for the data. So it can be annoying. But what's even worse is that all those search engine crawlers would see an empty page. And that can really hurt your search rankings because to those crawlers, your page doesn't have any content. So that's one important problem that's,
for example, solved by that seamless integration of frontend and backend and by blending that code and blending those two ends, so to say. Another thing that can get easier and possibly also more secure would be authentication because we can, of course, also authenticate users when building separated frontends and backends. For example, with JSON web tokens, that would be a popular approach.
But that approach also has certain disadvantages. For example, that those tokens are then the only thing that identifies a user. And if for some reason, such a token would get stolen, if an attacker could get hold of such a token of an authenticated user, they could basically assume their identity and then send requests on behalf of that user. Now, there are defense mechanisms
against that. For example, those tokens are typically short lived to make sure that if they do get stolen, they are not available for a long time period. But still, it can be a problem. And if you have a seamless integration, implementing session based authentication, where the authentication status is stored on the server instead of the client, implementing that is easier. And that can also add an extra layer of
security. It can also be easier than implementing authentication tokens, JSON web tokens, and storing them on the client. So that's another area where those meta frameworks and that seamless integration of backend and frontend can potentially solve certain problems, or at least make certain common things like user authentication easier and straightforward to implement. And that, of course, can be a great thing. There also is another advantage I see
when using such meta frameworks. And that would be that since you are in the end blending those ends, you can still use all the knowledge you have about React or Vue or Angular to render the user interface. And you can still add all that client side interactivity you want to add. Because the great thing about those meta frameworks is that once they did send back that first response that
contains all the content already, as I described, once that happened, it's again client side JavaScript that takes over and in the end gives the user this single page application experience again, where everything on the page is again updated by client side JavaScript code. And behind the scenes new data or new HTML code is fetched from the backend. But as a user of the website, you still have all the instant transitions and the
great user experience you often get from single page applications. So you keep those advantages, but you enrich them with more advantages. And of course, since you have that seamless integration, you do render all the content that's being sent back from the backend to the frontend on that first request. You do that all with the templating language you already know and love. So with JSX, for example, if you're using
React, you don't have to use a separate templating language to dynamically generate HTML code on the server. And that is what you would typically do when building backends that send back HTML instead of just data without such a meta framework. If you would build a backend with, for example, Node.js and Express, as many companies still do it because it is a fine
way, then you would typically either create an API, a REST API, for example, that's then used by a separated frontend. But if you want to build an integrated full stack application without such a meta framework, you would typically do that by using a templating engine on the backend in that Node Express code. And here you have popular options like EJS or handlebars and so on.
But these are all separate templating engines you have to learn so that you understand how you can use them to render the content you want to render. So it's an extra thing to learn. And then if you want to add client-side interactivity, you have to add React or Vue as an extra dependency to that project and manually write all the code that makes sure that it takes over once the page has been loaded in the
browser of your visitor. And you manually have to set up all the extra API endpoints, which then could be used by that frontend library if it wants to fetch or send new data after that initial first page load. So that would be more complex than using such a meta framework. And for all those reasons, I think that if you want to build a full stack application that has all the advantages you know from working with React or Angular or
Node, if you want to do that, then picking up such a meta framework is really important and a good idea. Now, it's also worth noting, though, that we're still in the early days of this entire development and evolution of frontend web development, if you want to call it like that. Of course, Next.js, for example, which is arguably the most important and popular meta framework for React, has
already been around for many years, but it's only been recently for one and a half years or probably two years now that they really moved quickly towards that integrated approach and towards a world where the frontend and backend code blend together and blend into each other, so to say. That's a relatively new development. And it is a development which we now see in other meta frameworks as well.
But it's still pretty new and therefore, of course, there still are some rough edges and some new patterns to be learned and some things to be understood to, for example, make sure, as I mentioned before, that your code doesn't end up on the wrong end and you're getting strange bugs or you're exposing data in places where it shouldn't be exposed. So there also are pitfalls related to that, also because it is so new.
But ultimately, as always in the world of programming, things will, of course, become better and smoother and patterns will emerge and certain problems will disappear. Well, and I guess new problems will appear, but you get my point. I think we're definitely heading towards such a world where those meta frameworks will be super important, though I will also say that this is still just one area of web development.
We absolutely still have those separated frontend and backend applications and we absolutely still have full stack applications where HTML code is rendered on the server with help of templating engines like EJS or, for example, in PHP-based backends with Laravel's Blade engine. So we definitely have those applications as well and actually those websites and applications are the majority.
So it's always important to keep in mind that we're in a niche here, nonetheless in an important niche, which I believe will grow because it offers certain advantages. And the advantage is that we have the best of both worlds, that single page application experience, the great user experience offered by that, combined with all the advantages of rendering content on the server and having such full stack applications.
Now, as mentioned, Next.js is arguably the most popular and important meta framework, but for React we, for example, also have Remix, which is a competitor to Next.js, if you want to call it like this, which is also growing in popularity and becoming more and more important and which offers, in my opinion, certain advantages over Next.js, though that probably would be a topic for a separate episode or video.
Nonetheless, you have these two options and if you are working with React, I would simply recommend that you take a look at both meta frameworks and you go through their quick start guides to see which one you like the most, for example. Now, if you're an Angular developer, there are less choices. Here you basically have analog.js and this is a project which, as far as I can tell, is a bit less mature than Next.js or
Remix. It doesn't have the same set of features and it has certain limitations, also because it's mainly developed by just one person. Though I believe that meta frameworks will be and will mostly become so important that we'll see more development in that area in the Angular world as well. Maybe because the Angular team makes analog.js or something like that an official extension of the Angular
framework, so we might see more development because of that or because more community projects come up. Now, if you're a Vue developer, things are actually different because there we do have a very popular and successful meta framework called Next.js and it's been around since 2017, I think, so it's really old by now but of course it has also evolved over all that time and I would say it's pretty comparable to Next.js
regarding its maturity, for example. Now, it works differently but the main idea is the same, that you can build full-stack applications with Vue and that you can blend back-end and front-end and it has many features that help you with that and that help you with building complex and user-friendly web applications and websites in general. And therefore, as web developers, we now essentially have one additional
option where besides traditional full-stack applications where we, for example, use Node, Express and then a templating engine like EJS or separated front-ends and back-ends, we now also have that very intriguing option of building full-stack applications where we get the best of both worlds by seamlessly integrating and blending front-end and back-end with those meta frameworks.
And of course, we have those rough edges you should be aware of and you should expect but those will absolutely become smoother in the future and therefore, I'm convinced that every React, Angular or Vue developer should also at least take a look at those meta frameworks.
GPT 6 Astra was released. It's a good model, I have to say. Especially for 3D work it seems to be a real game changer. But due to all the hype, you may be disappointed...