---
url: https://haihv.github.io/valifetch/api/auth/type-aliases/JwtRefreshOptions.md
---

# Type Alias: JwtRefreshOptions

> **JwtRefreshOptions** = `object`

Defined in: [src/auth.ts:27](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/auth.ts#L27)

Options for the [jwtRefresh](../functions/jwtRefresh.md) hook factory.

## Properties

### getToken

> **getToken**: () => `string` | `null` | `undefined`

Defined in: [src/auth.ts:29](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/auth.ts#L29)

Returns the current access token, or `null`/`undefined` if not yet set.

#### Returns

`string` | `null` | `undefined`

***

### isExpired

> **isExpired**: (`token`) => `boolean`

Defined in: [src/auth.ts:34](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/auth.ts#L34)

Returns `true` when the token must be refreshed before the next request.
Called only when `getToken()` returns a non-null value.

#### Parameters

##### token

`string`

#### Returns

`boolean`

***

### onRefreshed?

> `optional` **onRefreshed?**: (`token`) => `void` | `Promise`<`void`>

Defined in: [src/auth.ts:46](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/auth.ts#L46)

Persists the new token after a successful refresh (e.g. update a store).
Optional; may be synchronous or return a `Promise` — when it returns a
promise, the hook awaits it before attaching the refreshed token.

#### Parameters

##### token

`string`

#### Returns

`void` | `Promise`<`void`>

***

### refresh

> **refresh**: () => `Promise`<`string`>

Defined in: [src/auth.ts:40](https://github.com/haihv/valifetch/blob/285835d38a6676b98d2ee1a93e23166c6c834cb2/src/auth.ts#L40)

Fetches a fresh access token from the auth server.
Called at most once per concurrent refresh window — all queued requests
share the same in-flight refresh promise.

#### Returns

`Promise`<`string`>
