this composable will return the token currently save in your cookie, to refresh your token use refreshTokens

You can use this composable to get the jwt token, it is used internally to get the directus_token cookie.

Return: string

<script setup>const { token } = useDirectusToken();console.log(token.value);</script>


You can use this composable to get the expire time of your token in a UNIX timestamp format.

Return: number

<script setup>const { expires } = useDirectusToken();console.log(expires.value);</script>


Currently, we have plans to add auto refresh token as an opt-in feature, but there is no ETA. More info Issue 56

This composable function renews the token if you have a valid refesh_token in your cookie. The function will save the new token in the cookie if the renewal succeeds, if you don't need to manage the new token manually you can use the simple setup.

Return: DirectusAuthResponse

<script setup>const { refreshTokens } = useDirectusToken();refreshTokens();</script>
<script setup>const { refreshTokens } = useDirectusToken();const newToken = refreshTokens();</script>
Table of Contents