Migrating from Nuxt2 to Nuxt3

To be able to use the latest version of Storyblok I need to switch to nuxt3. It should be too much of an issue. Most things should be able to migrate over.

First I created a new project using the guide on their website and then I started following the migration guide.

The steps for me were as follows:

  • Copy over the eslint, git, and nuxt settings.

  • Remove Axios, since I should use fetch instead.

  • Remove GTM and replace it with a script tag in nuxt.config.js.

  • Add gtm and Storyblok using yarn.

  • Migrate components, layouts, pages, plugins, static, store, styles and utils.

  • Switch from to in layouts.

  • _slug.vue => [slug].vue.

  • Change from defineComponent to defineNuxtComponent.

  • Switch from adding composition API to just using ref(), pure functions, computed() etc without adding anything.

  • Rewrite plugins to use useNuxtApp.

  • Switch from <NuxtLink> to <a> for anchor links.

The site is now working with Nuxt3! Now I just need to make the content work, but since I am planning on switching to Storyblok I wont make the old content work.