API Reference

@sapphire/snowflake

Discord-style Snowflake ID generator with deconstruction, epoch configuration, and thread-safe increment.

Official Documentation ↗
CompatibilityThis documentation covers version v3.5. Check the official docs for the latest API surface.

Installation

npmnpm install @sapphire/snowflake

Methods

@sapphire/snowflake is discord-style snowflake id generator with deconstruction, epoch configuration, and thread-safe increment. This page documents the core methods, installation, and common usage patterns for the current stable release.

Installation

Install @sapphire/snowflake with your preferred package manager using the command shown in the frontmatter. The package is published to the npm registry and ships with TypeScript types where applicable.

Core methods

The methods listed in the frontmatter cover the primary API surface. Each signature reflects the v3.5 release. Consult the official documentation linked in sourceUrl for advanced options, edge cases, and breaking changes between major versions.

Frequently asked questions

The faq section in the frontmatter answers the most common questions about @sapphire/snowflake, including comparisons with alternatives, configuration tips, and runtime requirements. If your question is not covered, check the source URL for the full guide.

Errors

The official API reference declares the following error types:

API reference evidence

Fetched from official sources on 2026-11-08T09:53:13.312Z via WebFetch https://unpkg.com/@sapphire/[email protected]/dist/esm/index.d.mts.

FAQ

What is a Snowflake?
A 64-bit ID encoding timestamp, worker ID, and process ID; used by Discord and Twitter for sortable unique IDs.
Are IDs sortable?
Yes. Snowflakes are monotonically increasing within a worker, so they sort chronologically.
Can I use a custom epoch?
Yes. Set EPOCH before generating; use 1420070400000 for Discord or your own base.