# yggdrasil

> Mojang authentication (Yggdrasil) client

Latest version **1.8.0** (published 2026-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install yggdrasil
pnpm add yggdrasil
yarn add yggdrasil
bun add yggdrasil
```

## Health

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

Positive: no vulnerabilities; has provenance.

Warnings: low downloads; no types; no esm support.

## Facts

| | |
|---|---|
| Version | 1.8.0 |
| Published | 2026-03-30 |
| First published | 2014-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 30.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 47 |
| Author | Zeke Sonxx |
| Maintainers | rom1504, zekesonxx, wvffle |
| Keywords | minecraft, yggdrasil, authentication |

## Links

- npm: https://www.npmjs.com/package/yggdrasil
- Repository: https://github.com/PrismarineJS/node-yggdrasil
- Homepage: https://github.com/PrismarineJS/node-yggdrasil#readme
- Issues: https://github.com/PrismarineJS/node-yggdrasil/issues
- npm.io page: https://npm.io/package/yggdrasil

## Dependencies (2)

- [uuid](https://npm.io/package/uuid.md) ^10.0.0
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.1

## 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

- 1.8.0 (latest) — 2026-03-30
- 1.7.0 — 2022-03-27
- 1.6.1 — 2021-08-23
- 1.6.0 — 2021-03-27
- 1.5.2 — 2021-01-29
- 1.5.1 — 2021-01-29
- 1.5.0 — 2021-01-29
- 1.4.0 — 2020-12-05
- 1.3.0 — 2020-02-10
- 1.2.0 — 2020-02-02
- 1.1.1 — 2017-08-25
- 1.1.0 — 2017-08-14
- 1.0.0 — 2017-07-12
- 0.3.0 — 2017-07-12
- 0.2.0 — 2016-11-15
- … 4 more at https://npm.io/package/yggdrasil/versions

## README

# yggdrasil
[![NPM version](https://img.shields.io/npm/v/yggdrasil.svg)](http://npmjs.com/package/yggdrasil)
[![Build Status](https://github.com/PrismarineJS/node-yggdrasil/workflows/CI/badge.svg)](https://github.com/PrismarineJS/node-yggdrasil/actions?query=workflow%3A%22CI%22)
[![Discord](https://img.shields.io/badge/chat-on%20discord-brightgreen.svg)](https://discord.gg/GsEFRM8)
[![Gitter](https://img.shields.io/badge/chat-on%20gitter-brightgreen.svg)](https://gitter.im/PrismarineJS/general)
[![Irc](https://img.shields.io/badge/chat-on%20irc-brightgreen.svg)](https://irc.gitter.im/)

[![Try it on gitpod](https://img.shields.io/badge/try-on%20gitpod-brightgreen.svg)](https://gitpod.io/#https://github.com/PrismarineJS/node-yggdrasil)

A Node.js client for doing requests to yggdrasil, the Mojang authentication system, used for Minecraft and Scrolls.

# Usage
    $ npm install yggdrasil

## Client
```js
//init
const ygg = require('yggdrasil')({
  //Optional settings object
  host: 'https://authserver.mojang.com' //Optional custom host. No trailing slash.
});

//Authenticate a user
ygg.auth({
  token: '', //Optional. Client token.
  agent: '', //Agent name. Defaults to 'Minecraft'
  version: 1, //Agent version. Defaults to 1
  user: '', //Username
  pass: '', //Password
  requestUser: false //Optional. Request the user object to be included in response
}).then(
  (response)=>{},
  (error)=>{}
);

//Refresh an accessToken
ygg.refresh(oldAccessToken, clientToken, true).then(
  ({accessToken, clientToken, user?})=>{},
  (error)=>{}
);
// Note that requestUser is an optional parameter. If set to true, it requests the user object from Mojang's authentication servers as well.

//Validate an accessToken
ygg.validate(token).then(
  (response)=>{},
  (error)=>{}
);

//Invalidate all accessTokens using a current valid accessToken and clientToken.
ygg.invalidate(accessToken, clientToken).then(
  (response)=>{},
  (error)=>{}
);

//Invalidate all accessTokens
ygg.signout(username, password).then(
  (response)=>{},
  (error)=>{}
);
```

## Server
```js
const yggserver = require('yggdrasil').server({
  //Optional settings object
  host: 'https://authserver.mojang.com' //Optional custom host. No trailing slash.
});

//Join a server (clientside)
yggserver.join(token, profile, serverid, sharedsecret, serverkey).then(
  (response)=>{},
  (error)=>{}
);

//Join a server (serverside)
yggserver.hasJoined(username, serverid, sharedsecret, serverkey).then(
  (clientInfo)=>{},
  (error)=>{}
);
```
## Proxy Support
```js
const ProxyAgent = require('proxy-agent');

const ygg = require('yggdrasil')({
  //Any type of HTTP Agent 
  agent: new ProxyAgent('https://example.com:8080')
});
```

# Further Reading
* [Authentication protocol documentation](http://wiki.vg/Authentication)
* [node-minecraft-protocol](https://github.com/PrismarineJS/node-minecraft-protocol), a Minecraft client and server in Node.js

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