A Year With Nuxt.js - A Genuine Review of a Framework
Tags: nuxt, webdev, beginners, learning
Published: 2019-10-25 13:40:32

---
title: A Year With Nuxt.js - A Genuine Review of a Framework
published: true
cover_image: https://i.imgur.com/B1qwLvM.jpg
description: For more than a year I am working with nuxt.js on daily basis. In this review I would try to summarize all ups and downs while working with a framework. Hopefully this article may persuade you to try nuxt on your new project and you will also be aware of some caveats along the way, which I faced.
tags: nuxt, webdev, beginners, learning
---

---

For more than a year I am working with nuxt.js on daily basis. In this review I would try to summarize all ups and downs while working with a framework. Hopefully this article may persuade you to try nuxt on your new project and you will also be aware of some caveats along the way, which I faced.

---

**TL;TR**
- Have a year working with nuxt on daily basis.
- Nuxt is a very convenient and amazing for production.
- Nuxt is extendable and have lots of features and driven by vast and talented community
- Nuxt have caveats, which have some workaround but nothing is ideal :)

**Benefits**
- performant
- structure
- community
- documentation (guides for testing, guides for deploying)
- modules (i18n, sitemap, svg, apollo, axios, pwa, sentry, GA, GTM)

**Caveats**
- shared state problem (node problem)
- is-https and heroku (i18n multi domains, sitemap)
- `this` everywhere
- weak `rx.js` support

---

One remark before I start, I don't know if it was an idea, but I just love how nuxt logo is mountain, like you are behind a reliable wall.

![nuxt mountains logo](https://i.imgur.com/MUgyLLV.jpg)
<figcaption>nuxt mountains logo</figcaption>

![Using nuxt is like living in a mountains in calm and peace :)](https://i.imgur.com/B1qwLvM.jpg)
<figcaption>Using nuxt is like living in a mountains in calm and peace :)</figcaption>

#Project
First of all I want to give a small introfuction to the project. A year ago, in Oktober 2018 my friend [rami alsalman](https://medium.com/@ramialsalman9) (Ph.D. in machine learning!) approached me and shared the pain of using job websites nowadays, f.e. you are trying to find `Software Backend Engineer php` and you get a list of offers, with `python`, `C#`, `ASP.net` and so on.

All in all relevancy is poor sometimes because the recognition of offer description - like recognition of required programming skills, soft skills is the problem on it's own.

The idea was to build a search system only around machine learning algorythms that will recognise any job offer description text, any search text and applicant CV, so we could directly show most matching jobs based on CV.

That is how we came up with idea of [clusterjobs.de](https://clusterjobs.de). I was responsible for web application and became CTO of a startup and my friend became a CEO and machine learning search engine engineer.

![Search by CV with skills recognition](https://i.imgur.com/Z3pk03s.jpg)
<figcaption>Search by CV with skills recognition</figcaption>

#Why nuxt?
First of all I wanted to start a project with a long-term framework that will help us start fast and extend it in future. Other main point was to have SSR, cause we wanted to have *sustainable SEO* as a main traffic channel. Having php on a backend for SSR would lead to duplicating all the templates and double work, which we couldn't afford, cause the dev team is just me :).

I started to investigate javascript SSR solutions and nuxt seemed clearly a winner. There was 2.0.0 major release and good documentation, and decided to take a risk with a new technology on a new project and take nuxt as a framework for clusterjobs.

#Deployment and CD with nuxt
To save some time on manual deployments I invested couple of days to set up proper Gitlab pipeline to deploy app to heroku.
Here is a [great article on nuxt docs](https://nuxtjs.org/faq/heroku-deployment/) about deploying to heroku.
Here is a [great article on how to deploy vue on heroku](https://about.gitlab.com/blog/2017/09/12/vuejs-app-gitlab/) in gitlab Pipeline.
Combine them together and BOOM! That is what I have at the moment:

{% gist https://gist.github.com/starikovm/7652d0bdf6fc6efe5dfa6073029ea98d %}


---

#A year of development
After all environment was done it took roughly 2–3 months to prepare MVP and go live. Numerous iterations and improvements afterwards and till now I did not regret at any point of time that I chose nuxt.
So why is it good? I thought of really best moments that I experienced and here they are:

##Performance
It is performant, even though it is full js framework that need to deliver all library files to the client it still tries it's best to do it in less harmful way.

![93 points on performance metric in lighthouse](https://i.imgur.com/ysaQDwh.jpg)<figcaption>Lighthouse on slow 4G with 4x CPU slowdown on Mac pro</figcaption>

With last 2.10 update I found out guys have updated webpack config so during development only updated chunks are rebuild, which really speed up development. Also webpack for production is extendable and you could play around with it on your own, or use default config which is pretty performant on it's own.

{% gist https://gist.github.com/starikovm/7d5423052d695f78279874924cf93e9b %}

My webpack build config. Here are [the docs](https://nuxtjs.org/api/configuration-build/#extend) for this.

##Structuring
The good advantage is that I as a developer didn't need to think where to put this or that. Nuxt comes with a skeleton of app, with everything you need to build complex web app. Pages, components, assets, static, middlewares, plugins and so on.
The only thing that pissed me off is that nuxt encourages you to use `~/component/blah-blah` kind of stuff to import all over the application. 
So and JetBrains IDE, that I love with a bottom of my heart, couldn't recognise those pathes.

![WebStorm fails to recognise a path :(](https://i.imgur.com/0ckb1a5.jpg)<figcaption>WebStorm fails to recognise a path :(</figcaption>

Workaround for that is pretty simple:
{% gist https://gist.github.com/starikovm/f226fe7d10401f7cee86799b27ce759c %}
Name this file `phpstorm.webpack.config.js` (Cause it is PHPStorm and not WEBStorm in my case 😛) and put it in the root folder of your nuxt app to make `~` in you import pathes work!

![WebStorm is succeed to recognise a path now!](https://i.imgur.com/u7sqHPO.jpg)<figcaption>WebStorm is succeed to recognise a path now!</figcaption>


##Community
Community is living, huge thanks to {% user atinux %} who created nuxt itself and driving it till current moment, huge thanks to the Core Team and all contributors for such an amazing product. Probably if you tried nuxt you know these resources, but I just put them here:
 - [Brand new updated nuxt website](https://nuxtjs.org/guide/) with guides, docs and everything you might be interested
 - [Amazing platform for open source communities](https://cmty.app/nuxt). All Issues, questions and so on regarding nuxt and nuxt-community modules

##Modules
That is the thing that makes you love nuxt, really.
Coming from such a great community nuxt has readjusted vue modules, new modules, modules for everything. Found som not covered use-case in nuxt? Write a module, make it nuxt-community open source!
Here is a list of modules I use in production:
 - [**i18n**](https://github.com/nuxt-community/nuxt-i18n)
 Internationalisation, with multi-domains for each language, working out of the box. Like isn't it awesome? Languages and separate domains is crucial for SEO and could improve your presence in Google results list heavily. And here you just need to add module, integrate it with your UI and that's it.

 - [**sitemap**](https://github.com/nuxt-community/sitemap-module)
 Also super important thing that is needed for every prod website. This module will generate sitemap based on your routes. You could also use axios th request your API and get all dynamic routes or whatever you want.
 - [**svg**](https://github.com/nuxt-community/svg-module)
 Use svg all over the app, but load them from auto-generated sprite
 - [**apollo**](https://github.com/nuxt-community/apollo-module)
 GraphQL is awesome!
 - [**pwa**](https://github.com/nuxt-community/pwa-module)
 PWA is our future, try to investigate this topic, if you still haven't done it yet! Upd. Samsung started to show PWA apps in Galaxy store!
 - [**sentry**](https://github.com/nuxt-community/sentry-module)
 get to know your user's pain with awesome service that will log all production errors for you.
 - [**GA**](https://github.com/nuxt-community/analytics-module), [**GTM**](https://github.com/nuxt-community/modules/tree/master/packages/google-tag-manager)
 Necessary evil to track you app performance



---

#Caveats
There was some problems of course during the year of working with nuxt.
Now I ll try to give context for each of them and help you avoid them in future:

##Shared state on multiple requests in nuxt
This is related to how node.js works. If you have a global variable, it will be overwritten in simultaneous request.
Some insights are given in this [Stack Overflow question](https://stackoverflow.com/questions/48550284/how-to-keep-multiple-requests-separate-in-nodejs-expressjs).
The problem that I experienced was related to fetch function on my offer-list page (search results).
I was making action call like
{% gist https://gist.github.com/starikovm/f226fe7d10401f7cee86799b27ce759c %}


Making search on server sideThat was done to populate store on server side and use the same offers on client side.
But when it is done inside action, like `action -> commit -> store` then for some reason that data is mixed.
I confess, I did not investigate the true reason of that, maybe some global object of Vuex store or something like that, but the problem was that
while I had my application running for first request, every next request got it's state. So you might end up landing here [https://en.clusterjobs.de/search/fullstack developer](https://en.clusterjobs.de/search/fullstack developer) and having machine learning engineer results.
Fix for that was:
{% gist https://gist.github.com/starikovm/74462288a4affe0542a9b705383ffc59 %}
Committing directly from fetch function.

So `action -> back to fetch -> commit -> state`. Action should return a Promise wich is resolved with proper data, which you could use back in `fetch` function.
Probably after that point commit calls where close to the end of fetch and page had correct data, but general problem might be still here.

##Heroku and is-https
I am hosting app using `cloudflare` for DNS and `heroku` as a server. Pointing domain to heroku is done through `CNAME`. Which is giving me some problems.
Several modules of nuxt (sitemap, i18n) are using is-https library to identify on server side the type of request.
The request which is done to cloudlfare is https, but probably that proxying is not.
I got some [advices in CMTY](https://cmty.app/nuxt/sitemap-module/issues/c69) on that.

Enabling **x-forwarded-proto** should help, but I didn't try it so far

##`this` everywhere
Personally I like to write functional code in js. It is possible with nuxt but all the modules makes you use this.
Want to get current locale in vuex store or in component? `this.app.i18n.locale`
THe same for switching locale and getting all locales list.
Wnat to change page in Vuex? 
`this.router.push`
I can live with that, but having those objects as an arguments inside functions also could benefit for better code separation.

##`Rx.js`
I love RX and love to apply it to especially state managing use cases.
RX could be integrated to vue js and to nuxt as well, if we are talking about DOM events. There is this package:
[https://github.com/vuejs/vue-rx](https://github.com/vuejs/vue-rx)
To integrate it to nuxt, just create a plugin like this:

{% gist https://gist.github.com/starikovm/bee6bcd3ee7b045e593b8a69008195f7 %}

Put this file into plugins folder and add the plugin in `nuxt.config.js`. There were also couple of trials to integrate it into vuex, but so far repo is deprecated, and I haven't seen any articles regarding this in the late time.

---

#Summarize
All in all I love nuxt, I even prepared a workshop for my fellow colleagues and did it couple of times to spread the knowledge and encourage them to try it.
I think it is a very mature and developed tool for any need. You could use it for everything starting from simple static landing, personal website, up to complex web application and ecommerce platform.
I faced some caveats, which are feasible to fix, but also I had a lot of great moments, when everything so simple and works so awesome.
I truly believe in that framework and deeply grateful to people that created it and are maintainig it till this very moment.
**Thank you, nuxt, nuxt :P**