🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
Socket

@elysiajs/jwt

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@elysiajs/jwt

Elysia plugin to integrate JSON Web Tokens (JWT)

latest
Source
npmnpm
Version
1.4.2
Version published
Weekly downloads
48K
2.7%
Maintainers
1
Weekly downloads
 
Created
Source

@elysia/jwt

Elysia plugin to integrate JSON Web Tokens (JWT).

Installation

bun add @elysia/jwt

Example

import { Elysia, t } from 'elysia'
import { jwt } from '@elysia/jwt'

const app = new Elysia()
	.use(
		jwt({
			name: 'jwt',
			// This should be Environment Variable
			secret: 'MY_SECRETS'
		})
	)
	.get('/sign/:name', async ({ jwt, cookie: { auth }, params }) => {
		auth.set({
			value: await jwt.sign(params),
			httpOnly: true
		})

		return `Sign in as ${params.name}`
	})
	.get('/profile', async ({ jwt, set, cookie: { auth } }) => {
		const profile = await jwt.verify(auth)

		if (!profile) {
			set.status = 401
			return 'Unauthorized'
		}

		return `Hello ${profile.name}`
	})
	.listen(3000)

See documentation for more details.

Keywords

elysia

FAQs

Package last updated on 23 Apr 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts