# react-jwt

> Small library for decoding json web tokens (JWT)

Latest version **2.1.1** (published 2026-04-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-jwt
pnpm add react-jwt
yarn add react-jwt
bun add react-jwt
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.1.1 |
| Published | 2026-04-05 |
| First published | 2020-08-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=16 |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 49 |
| Author | Gustavo Velazquez |
| Maintainers | gustavo0197 |
| Keywords | jwt, react jwt, jsonwebtoken, react, auth, authentication |

## Links

- npm: https://www.npmjs.com/package/react-jwt
- Repository: https://github.com/gustavo0197/react-jwt
- Homepage: https://github.com/gustavo0197/react-jwt#readme
- Issues: https://github.com/gustavo0197/react-jwt/issues
- npm.io page: https://npm.io/package/react-jwt

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 2.1.1 (latest) — 2026-04-05
- 2.1.0-beta.0 (beta) — 2026-04-05
- 2.1.0 — 2026-04-05
- 2.0.0 — 2025-11-18
- 2.0.0-beta.3 — 2025-11-10
- 1.3.0 — 2025-03-14
- 1.2.2 — 2024-07-24
- 2.0.0-beta.1 — 2024-03-24
- 1.2.1 — 2024-03-18
- 1.2.0 — 2023-06-09
- 1.1.8 — 2023-01-13
- 1.1.7 — 2022-09-22
- 1.1.6 — 2022-05-02
- 1.1.6-beta.2 — 2022-05-02
- 1.1.6-beta.1 — 2022-05-02
- … 14 more at https://npm.io/package/react-jwt/versions

## README

# react-jwt

> Small library for decoding json web tokens (JWT)

[![NPM](https://img.shields.io/npm/v/react-jwt.svg)](https://www.npmjs.com/package/react-jwt)

## Install

```bash
npm install react-jwt
or
yarn add react-jwt
```

## Usage

```jsx
import React from "react";
import { useJwt } from "react-jwt";
const token = "Your JWT";

const Example = () => {
  const { decodedToken, isExpired } = useJwt(token);
  /*
    If is a valid jwt, 'decodedToken' will be a object
    it could look like:
    {
      "name": "Gustavo",
      "iat": 1596408259,
      "exp": 4752168259
    }

    'isExpired' will return a boolean
    true => your token is expired
    false => your token is not expired
  */

  return (
    <div>
      ...
    </div>
  );
};
```

You can also use the methods isExpired(token) and decodeToken(token)

```jsx
import React from "react";
import { isExpired, decodeToken } from "react-jwt";
const token = "Your JWT";

const Example = () => {
  const myDecodedToken = decodeToken(token);
  const isMyTokenExpired = isExpired(token);

  return (
    <div>
      ...
    </div>
  );
};
```

## Refresh state
If you use the reEvaluateToken(newToken) method, useJwt's state will be updated

```jsx
import React from "react";
import { useJwt } from "react-jwt";
const token = "Your JWT";

const Example = () => {
  const { decodedToken, isExpired, reEvaluateToken } = useJwt(token);

  const updateToken = () => {
    const newToken = "A new JWT";
    reEvaluateToken(newToken); // decodedToken and isExpired will be updated
  }

  return (
    <div>
      ...
    </div>
  );
};
```


## License

MIT © [@gustavo0197](https://github.com/@gustavo0197)

---
_Source: https://npm.io/package/react-jwt · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
