useTokenStorage()
useTokenStorage()
is a specialized composable for managing authentication tokens, particularly in applications using token-based authentication (authMode: 'token'
).
Features
Set Token: The composable allows you to store a new authentication token in your application. This is essential for maintaining user sessions in token-based authentication setups.
Example:
javascriptconst nuxtApp = useNuxtApp(); useTokenStorage(nuxtApp).set('token-value');
Get Token: You can also retrieve the stored authentication token, enabling you to include it in API requests or other operations that require the token.
Example:
javascriptconst nuxtApp = useNuxtApp(); const token = useTokenStorage(nuxtApp).get();