Nuxt.js over Vue.js: when should you use it and why
bornfight.com
bornfight.com
Also routing is a mess. Really no way to set up routing in a decent, understandable way.
So in my opinion just use Nuxt when you are sure your website is not going to need any complex functionality that is easily achievable with a server middleware. Pretty sure that there are other ways to achieve good SEO and in general Search Engine indexation without giving up so much.
I worked on a project built with Nuxt about a about a year ago and I really didn't like it. Everything felt like a chore.
A better example of a static site generator would be something like Jekyll (https://jekyllrb.com/)
NextJS
NestJS
why all these frameworks have very similar names? it is very confusing every time I read a news about one of them I wonder which one is which.
If there was one time when we could have escaped the client side hell that is JavaScript it would have been then, when chrome had astonishing market share, and Dart could compile down to JS to ease the transition until native support became standardized.
But nope, here we are with anotherone.js every week.
Case in point: Angular has an alternative Dart implementation which is AFAIK used by Google internally, but it didn't take the web by storm and currently the TS flavour is by far the dominant one.
I think we're very lucky that Chrome never decided to include that Dart VM. Typescript turned out to be much better than Dart.
I think we can agree to disagree. I would much rather use Dart, imo.
NestJS is probably a coincidence.
The article's very first words are: Nuxt.js is a frontend framework built upon Vue.js so I think it's more of a semantics thing on what he meant by "over" (i.e. on top of vs. replaces).
They're two different kinds of projects, with different trade-offs, even though the underlying front end framework is the same.
Perhaps useful to some sites. Assuming Google has issues with Vue. Not useful for someone doing content behind a sign-in that isn’t going to ever be SEOed anyway?
Generally, it feels like it strikes a good balance between being fully configurable boilerplate and opinionated framework.
I don’t send JS, my CDN does, so not a big win there.
There are other points in favor of doing SSR + hydration besides SEO:
1) Reducing the amount of JS you are sending to the client.
2) Not making a SPA and keep the native functionality of back/forward behavior (scroll behavior, cached pages, forms are filled when going back).
3) Simplifying development. You don't need to manage central state anymore as you're dealing with one page at a time. You might not need an API as you're rendering the page from the server. Etc.
I've been making SPAs for years and for my current project I'm doing SSR + hydration (not using Vue) and loving it.
It reduces the JavaScript sent to each page even further because it doesn't have a runtime per se. Basically each component is "compiled" to a set of imperative DOM instructions with some helper functions.
Hopefully they will get there one day but so far it gives me the feeling that I could hit a dead-end with it at any time.
Sometimes I hit a little bump on the road which would be faster/easier to solve in React/Vue/etc but even including those slowdowns I save so much net dev time it's crazy.
1. Nuxt can runs in SPA mode just like using Vue CLI. The opposite is not true
2. SEO is the winning feature of Nuxt, no doubt.
3. Real server status code: especially useful for redirections and 404 pages. For example if you do `curl -I /some-page-that-does-not-exist`, you will get back 404 status code, which is critical for sitemaps and uptime tools. (Instead in SPA you always get 200 for all the pages).
4. Pages written in Nuxt seems to display faster, because the HTML is sent immediately. I say "display" here, not necessarily "load" faster.
5. Real Express middleware helps a lot when doing route validations and authorizations. You can also make calls to private API without exposing them on the client side.
6. Can adjust the amount of HTML sent to client by wrapping client-side-only components in a <client-only> component. Which means that on the server you don't need to generate giant HTML for a simple datepicker, and let the browser does that
Naively it seems a trivial problem, but I guess that SEO for SPA is not as trivial as I imagine?
Imagine you build an e-commerce website that has ten thousands of products, that can be accessed by example.com/products/{product-slug}. Now what is making more sense: 1. Generating ten thousands of .html file for each products in the DB 2. Use routing in Nuxt like this "/products/$productSlug" and query for $productSlug in the database
To me the (2) approach is a clear winner here. And the performance only depends on how fast your API can query a single product from the database, which is pretty fast 99% of the time.
Going to the website it wants me to install .. Safari 13.
They do have a kind of weird plugin/module system that I worry is an overly complicated layer of abstraction - basically, stuff that would normally be manually hooked up in your server or client entry point script now gets called automatically by Nuxt at various points. Still, it is useful for setting up things like authentication (e.g. parse cookies on server and set auth headers in Axios).
They're also still iterating on the public API, though they've been pretty careful to deprecate without breaking things. Like, the fetch() hook that used to be used to load data at a page level (e.g. "before transitioning to this route, load this set of data") was totally overhauled to now be "load data for this component," with no "pre-transition await" available anymore (https://nuxtjs.org/blog/understanding-how-fetch-works-in-nux...). This is a good change, but an example of the complex problems that come up in these SSR frameworks, and why they end up being a lot more complex than just simple wrappers around the ecosystem. You really have to buy in when you use a framework like this, more than just buying into Vue itself.
I did see that they just raised a seed round (https://nuxtjs.org/blog/seed-round), which is surprising to me. I don't see a lot in that announcement about how they're going to make money, which is a bit scary. Over in React-land, of course, Next.js is nominally owned by Vercel (formerly Zeit), which is also venture-backed, but Next is related to their primary revenue stream while not being at all the main focus of the company, which is probably the right spot for this sort of thing.
Moving to Vue 3 will be a problem for Nuxt, I think, because of the abstractions they've built on top of Vue.
(also, glad this post came up because while double-checking to see how big Nuxt is in my app, I realized I was failing to gzip my client assets because I misconfigured Caddy, gah!)
Yet, especially for ERP projects, most of those features are problematic. Like SEO. I don't want a search engine to ever see my content. In fact, my robots.txt says not to index it. SSR is a non starter, since everything would vary based on the user, we're just shifting the rendering back to the server, for no real gain other than the round trips on the api. The routes can be a problem as well. My routes have different navigation guards depending on permissions and state for the user, i haven't checked but i doubt auto generated guards based on folder structure wouldn't handle our weird business logic. COmbined with the difficulty of dealing with errors server side, nuxt.js isn't going to work in these kinds of cases.
TL;DR Nuxt.js does not work for everyone, even if people say it does.
It's very much on a different scale of complexity than a todo app. Or any app that 'does one thing well'. I think a lot of devs forget this when talking about what everyone MUST do, or making recommendations like a form should never have more than 5 fields.
Most of the ssr for performance is around how a couple extra milliseconds will increase your bounce rate. For some of us, if our users bounce, they get fired, because the site is the tool they use to do their job. (but we should always endeavour to be performant, because we don't want to make their job more miserable) So things like bounce rate doesn't matter.
Sharing filtered links or storing filtered links in your favorites becomes impossible when the query parameters don't change.
The only time it was slow is if the browser itself was old (e.g. Chrome 44).
The solution is to have a performance budget at the start of your project so things never get so bad.
The quagmire of subtly different JavaScript frameworks is definitely the leading reason I avoid front end work like the plague.
I’d love to see a “modern” web app built in pure JavaScript without a framework.