Custom routes with Nuxt and Layer0

I was able to have Nuxt routes working with the default router property. However, creating custom routes with the @nuxtjs/router module seems incompatible with Layer0? (When enabled, all routes are returning 404 errors).

For reference, here is an example router config using @nuxtjs/router:

// router.js
import Vue from 'vue'
import Router from 'vue-router'

import MyPage from '~/components/my-page'


export function createRouter() {
  return new Router({
    mode: 'history',
    routes: [
        path: '/',
        component: MyPage
        beforeEnter: (to, from, next) => {
          // ...

Is there any recommended approach or code example on how to use similar config with Nuxt.js and Layer0?

The layer0-nuxt package doesn’t understand custom routes, but you can simply add the same routes to your Layer0 router (routes.js) and use renderWithApp to forward requests to your nuxt app. For example:

// routes.js
const { Router } = require('@layer0/core/router')

new Router()
  .get('/', ({ renderWithApp }) => {
1 Like