Skip to content

Jwt

Wrapper for jwt-decode.

⚡️ Prerequisites

  • Install the jwt-decode package:
$ pnpm add jwt-decode

---> 100%

🎬 Usage

<script>
    import {jwt} from "svelteintegrations/jwt"

    const token = ""

    const { header, payload } = jwt(token)
</script>

<h1>Header: {JSON.stringify(header)}</h1>

<h1>Payload: {JSON.stringify(payload)}</h1>

👩‍💻API

Arguments

Name Description Type Required
token The token to decode string Yes

Options

Name Description Type Default
fallback_value The value to return if the token is invalid any null
on_error The function to call if the token is invalid function No default

Returns

Name Description Type
header The header of the JWT object
payload The payload of the JWT object

🧪 Playground


Last update: 2022-10-21