Files
fuel-price/.agents/skills/vueuse-functions/references/useJwt.md
Ovidiu U 4a3ce4cc1d
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (8.3) (push) Has been cancelled
tests / ci (8.4) (push) Has been cancelled
tests / ci (8.5) (push) Has been cancelled
docs: add advanced skills for Vitest, Pinia, and Vue built-ins
Add comprehensive reference documentation for:
- Vitest: environments, projects/workspaces, type testing, vi utilities
- Pinia: HMR, Nuxt integration, SSR setup
- Vue: built-in components (Transition, Teleport, Suspense, KeepAlive) and advanced directives
2026-04-11 16:28:36 +01:00

58 lines
1.2 KiB
Markdown

---
category: '@Integrations'
---
# useJwt
Wrapper for [`jwt-decode`](https://github.com/auth0/jwt-decode).
## Install
```bash
npm install jwt-decode@^4
```
## Usage
```ts
import { useJwt } from '@vueuse/integrations/useJwt'
import { defineComponent } from 'vue'
const encodedJwt = ref('eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwiaWF0IjoxNTE2MjM5MDIyfQ.L8i6g3PfcHlioHCCPURC9pmXT7gdJpx3kOoyAfNUwCc')
const { header, payload } = useJwt(encodedJwt)
```
## Type Declarations
```ts
export interface UseJwtOptions<Fallback> {
/**
* Value returned when encounter error on decoding
*
* @default null
*/
fallbackValue?: Fallback
/**
* Error callback for decoding
*/
onError?: (error: unknown) => void
}
export interface UseJwtReturn<Payload, Header, Fallback> {
header: ComputedRef<Header | Fallback>
payload: ComputedRef<Payload | Fallback>
}
/**
* Reactive decoded jwt token.
*
* @see https://vueuse.org/useJwt
*/
export declare function useJwt<
Payload extends object = JwtPayload,
Header extends object = JwtHeader,
Fallback = null,
>(
encodedJwt: MaybeRefOrGetter<string>,
options?: UseJwtOptions<Fallback>,
): UseJwtReturn<Payload, Header, Fallback>
```