How to type a custom Nuxt plugin instance in TypeScript?
I'm integrating Keycloak into my Nuxt 4 app with SSR disabled (SPA mode). I created a plugin to initialize Keycloak and provide the instance globally via nuxtApp.provide('keycloak', keycloak).
I want to:
Make $keycloak strongly typed when using const { $keycloak } = useNuxtApp()
Use this $keycloak instance to fetch data from a resource server (adding the access token automatically and refreshing it before expiry)
Ensure the plugin execution order so that $keycloak is available before other plugins (e.g., Axios) use it
What's the best way to structure my plugin, type declarations, and token refresh logic so that everything works smoothly in Nuxt 4 SPA mode?
I want to:
Make $keycloak strongly typed when using const { $keycloak } = useNuxtApp()
Use this $keycloak instance to fetch data from a resource server (adding the access token automatically and refreshing it before expiry)
Ensure the plugin execution order so that $keycloak is available before other plugins (e.g., Axios) use it
What's the best way to structure my plugin, type declarations, and token refresh logic so that everything works smoothly in Nuxt 4 SPA mode?
