---
title: "AdonisJS JWT"
description: "Production JWT authentication for AdonisJS v7."
image: "https://adonisjs-jwt.pages.dev/og.png"
---

> Documentation Index
> Fetch the complete documentation index at: https://adonisjs-jwt.pages.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# AdonisJS JWT

`@rikology/adonisjs-jwt` is an AdonisJS v7 auth guard built around short-lived JWT access
tokens and hashed, rotating opaque refresh tokens.

## Why this package

- **Strict verification:** pinned algorithms plus required issuer, audience, subject, ID, and time claims.
- **Safe renewal:** one-time refresh rotation, family lineage, replay detection, and bulk revocation.
- **Deployable key management:** environment, encrypted database, HS256, and remote-JWKS drivers.
- **Browser-ready transport:** hardened `httpOnly` cookies with double-submit CSRF protection.
- **Operations built in:** public JWKS, zero-downtime rotation, typed events, stable JSON errors, and OpenTelemetry spans.

## Requirements

- Node.js 24 or newer
- AdonisJS 7 and `@adonisjs/auth` 10
- `@adonisjs/lucid` 22 for the built-in refresh-token store and database key driver

## Quick start

```sh
node ace add @rikology/adonisjs-jwt
node ace jwt:make-key
node ace migration:run
```

Then [register the guard](/configuration/) and protect a route:

```ts
router
  .get('/me', ({ auth }) => auth.getUserOrFail())
  .use(middleware.auth({ guards: ['jwt'] }))
```

The generated controller demonstrates login, refresh, logout, and logout-all. Continue with
[the token lifecycle](/lifecycle/) before exposing those endpoints.

Source: https://adonisjs-jwt.pages.dev/overview/index.mdx
