@arunpradeepvn/jwt-utility
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

JWT Utility

A simple utility for decoding JWT (JSON Web Tokens) in TypeScript.

Supported in Expo, React Native, React.js and Node.js.

Installation

You can install the package via npm:

npm install @arunpradeepvn/jwt-utility@latest

You can install the package via yarn:

yarn add @arunpradeepvn/jwt-utility@latest

Usage

Importing the Utility

You can import the decodeJWT function from the package:

import { decodeJWT } from '@arunpradeepvn/jwt-utility';

Decoding a JWT

To decode a JWT, use the decodeJWT function:

const token = 'YOUR_JWT_TOKEN_HERE';
try {
    const decoded = await decodeJWT(token);
    console.log(decoded);
} catch (error) {
    console.error('Failed to decode token:', error);
}

API

decodeJWT(token: string): Record<string, any>

token: A JWT string to decode.

Returns: The decoded payload as a JSON object.

Package Sidebar

Install

npm i @arunpradeepvn/jwt-utility

Weekly Downloads

1

Version

1.0.7

License

MIT

Unpacked Size

4.66 kB

Total Files

5

Last publish

Collaborators

  • arunpradeepvn