javascript - Migrating to Nuxt 3 from Vue 2? - Stack Overflow

There is a medium-sized application written in Vue 2.7 (vuex, vue-router, etc.).Until a certain point,

There is a medium-sized application written in Vue 2.7 (vuex, vue-router, etc.).

Until a certain point, we had SSR "with our own hands." Works crookedly and slowly, but works.

Recently, it has ceased to satisfy the needs of the project and we realized that we would be migrating to Nuxt.

Relatively recently, Nuxt 3 was released. It is now in rc state. We are betting on the further development of Nuxt. Therefore, we want to migrate to version 3. In addition, I think that in the near future we will consider switching to TypeScript, and in Nuxt 3 TS support is at a good level.

But there is an ambiguity: Nuxt 3 works with Vue 3. Also, it is remended to use pinia instead of Vuex.

In this regard, questions:

  1. Will most ponents work on Vue 2 when using Nuxt 3? I also want to move to Vue 3, but for now we want to speed up the process as much as possible. But I don't want to use crutches like "Vue 3 Migration Build" either.
  2. Is Pinia definitively replacing Vuex? I mean, is Vuex going to be obsolete anytime soon?
  3. Maybe there are more pitfalls that you should know BEFORE moving?

There is a medium-sized application written in Vue 2.7 (vuex, vue-router, etc.).

Until a certain point, we had SSR "with our own hands." Works crookedly and slowly, but works.

Recently, it has ceased to satisfy the needs of the project and we realized that we would be migrating to Nuxt.

Relatively recently, Nuxt 3 was released. It is now in rc state. We are betting on the further development of Nuxt. Therefore, we want to migrate to version 3. In addition, I think that in the near future we will consider switching to TypeScript, and in Nuxt 3 TS support is at a good level.

But there is an ambiguity: Nuxt 3 works with Vue 3. Also, it is remended to use pinia instead of Vuex.

In this regard, questions:

  1. Will most ponents work on Vue 2 when using Nuxt 3? I also want to move to Vue 3, but for now we want to speed up the process as much as possible. But I don't want to use crutches like "Vue 3 Migration Build" either.
  2. Is Pinia definitively replacing Vuex? I mean, is Vuex going to be obsolete anytime soon?
  3. Maybe there are more pitfalls that you should know BEFORE moving?
Share Improve this question edited Sep 19, 2022 at 11:25 kissu 47k16 gold badges90 silver badges189 bronze badges asked Sep 19, 2022 at 9:51 OleksandrOleksandr 4751 gold badge9 silver badges20 bronze badges 5
  • 4 I did a Vue 2 => Vue 3 upgrade on a big client project recently. I think the difficulty largely depends on which libraries you are using and whether they are patible. We had troubles with our extensive dependency on bootstrap-vue and vue-class-ponent in particular, which are not Vue 3 friendly. – Evan Summers Commented Sep 19, 2022 at 9:56
  • 1 "Will most ponents work on Vue 2 when using Nuxt 3" - your primary concern is Vue 3 patibility, not Nuxt. No, a lot of them don't work if they aren't written with V2/3 patibility in mind. "Is Pinia definitively replacing Vuex" - it's a replacement for unreleased Vuex 5. Pinia is more TS-friendly than Vuex – Estus Flask Commented Sep 19, 2022 at 10:08
  • 1 Read the Pinia documentation, like everything from vuejs, it's thorough and very easy to read, there are a couple of gotchas, though I think I misread the documentation to be honest - I can also tell you the pain in upgrading vue2 to vue3 is mainly other frameworks patibility - in my case, vuetify – Jaromanda X Commented Sep 19, 2022 at 11:04
  • @Toggle, We are using a few ponents from bootstrap-vue: "^2.15.0". And also vuelidate. There are others, but they all have a very low share of the codebase. – Oleksandr Commented Sep 19, 2022 at 11:11
  • 1 @kissu, No, my manager is pulling, because during the migration there will be no introduction of new functionality. However, we are still going to start in a week or two. Will post here when there is news – Oleksandr Commented Oct 23, 2022 at 18:49
Add a ment  | 

1 Answer 1

Reset to default 6

I would first off migration from Vue2 to Nuxt2, for the simplest + fastest approach without too many breaking parts. That way, you can at least benefit of some SSR capabilities until your whole migration is done.

Then, as Estus Flask said, the main issue would be the packages themselves (like Vuetify, which are still not fully Vue3 patible in a stable state).

Also, you can totally migrate to Nuxt3 while keeping most of your ponents with the Options API (no need to refacto towards Composition API).

Nuxt3 is runnable in production but you may still need to troubleshoot it depending on what you are planning to use. Also, keep in mind that not all the modules are migrated yet, here is the latest roadmap.

So to answer your questions:

  • depending on how your ponents are now, you may need to update some of their parts, for further details you can check the migration guide and see if you are anyhow impacted by the changes when going from Vue2 to Vue3. If you want to iterate faster (and in a safer way), migrate to Nuxt2 first (should be quite fast!), then try to move towards Nuxt3
  • Pinia is better on pretty much all aspects when pared to Vuex. Will it be un-usable in the next 18 months? Probably not. It's still the official remendation and will be the way to go overall (it's just better overall) but Vuex is still totally usable as of today. More details can be found here
  • as always, you gonna add a layer on top of Vue so it may impact several things:
    • depending on the amount of features you are using (Nuxt modules, Nuxt specific modules), some releases may take a bit more time overall to ship to production (using Tailwind with Vue3 was made possible earlier in parison of Nuxt3)
    • Nuxt is a meta-framework, so it will bring some amount of plexity to properly understand all the Nuxt2 hooks, the way an isomorphic app works, how to use Vue2 packages, some gotchas etc... This is not ing from Nuxt itself, but more from the SSR part.
    • Nuxt3 is using Vue3, so you will need to then understand a bit more how position API works to get the benefit of using useAsyncData posables etc... So the same work will be needed there too, hence why I remend a transition to Nuxt2 first. Of course, it all depends of your team and if your members are already at ease with Composition API

Overall, if you need a production-grade solution for your SSR needs, it will be quite useful to use Nuxt for sure but it will also require a bit of a learning curve.
You will also get quite some DX out of it, so that's a nice bonus!

Also, there is no real petition to Nuxt in Vue's ecosystem so at least, you don't need to fully pare meta-frameworks. AstroJS could be another approach but it goes out from the Vue ecosystem quite a lot overall (you won't benefit of Nuxt's modules/nice features for example) and solves some specific needs.

PS: Nuxt's team is working on the same approach regarding server-only ponents + heavy improvements regarding the hydration.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744757717a4591982.html

相关推荐

  • javascript - Migrating to Nuxt 3 from Vue 2? - Stack Overflow

    There is a medium-sized application written in Vue 2.7 (vuex, vue-router, etc.).Until a certain point,

    5小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信