Nuxt 2 Bridge: How to set a middleware on a page?

Viewed 14
1 Answers

In Nuxt 2 Bridge middlewares are still set the old non-composition way. This can be used next to the composition API:

<template>
  <div />
</template>

<script setup lang="ts">
onMounted(() => {
  useNuxtApp().nuxt2Context.$auth.login()
})
</script>

<script lang="ts">
export default {
  middleware: ['auth'],
}
</script>
Related