# paralleldrive/cuid

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/paralleldrive-cuid).**

_How this analysis was created: the description and tags below were written by an AI model that read this project's README and public documentation pages; stars, license and language come straight from the GitHub API. The model does not read the source code._

3,503 stars · 117 forks · JavaScript · NOASSERTION

## Links

- GitHub: https://github.com/paralleldrive/cuid
- Homepage: https://usecuid.org
- awesome-repositories: https://awesome-repositories.com/repository/paralleldrive-cuid.md

## Description

Cuid is a JavaScript library that generates collision-resistant unique identifiers. Each id is built from a timestamp, a counter, a machine fingerprint, and random blocks, so records can be created on many servers and browsers without a central coordinator. Generation is synchronous and local, which lets a client build a complete record and insert it without asking the database to assign a key. The repository also documents the id format as a specification, and it is marked as deprecated: the format leaks timestamps and is considered insecure, so a newer successor is recommended instead.

The ids begin with a fixed letter and use only lowercase base-36 characters, so they work directly as HTML element ids and in URLs. Because values increase roughly with creation time, they are suited to sortable database primary keys. The library also offers a short slug function that returns seven to ten characters for disambiguating URLs. Slugs trade uniqueness and unguessability for brevity, so they should not be used as database keys or to protect private resources. A validation helper checks whether a string is a well-formed full id or a slug.

The same code runs in Node, browsers, and mobile runtimes. The build ships a server module and a minified browser bundle, and swaps in environment-specific sources for the fingerprint and random values. The fingerprint method can be overridden, and the algorithm can be reimplemented in other languages and on other platforms while keeping the same id format.

Continuous integration runs the test suite across several Node versions and in real Chrome and Firefox under a virtual display. A dependency update bot is configured to merge minor updates automatically and hold major-version bumps for manual review.

## Tags

### Part of an Awesome List

- [Unique ID Generation](https://awesome-repositories.com/f/awesome-lists/devtools/unique-id-generation.md) — Generates short, unique ids from a timestamp, counter, and per-client fingerprint so records stay distinct across servers and browsers. ([source](https://github.com/paralleldrive/cuid/blob/master/package.json))

### Data & Databases

- [Composite Identifier Structures](https://awesome-repositories.com/f/data-databases/composite-identifier-structures.md) — Builds each id by concatenating a timestamp, rolling counter, machine fingerprint, and random blocks for uniqueness and rough time ordering.
- [Client-Side ID Generation](https://awesome-repositories.com/f/data-databases/offline-data-management/client-side-id-generation.md) — Runs synchronously in browsers and Node so full records can be created and inserted without asking a database to assign a key. ([source](https://github.com/paralleldrive/cuid#readme))
- [Time-Sortable Primary Keys](https://awesome-repositories.com/f/data-databases/time-sortable-primary-keys.md) — Produces ids that increase roughly with creation time, making them suited to sortable database primary keys and efficient lookups. ([source](https://github.com/paralleldrive/cuid/blob/master/README.md))
- [Client-Generated Keys](https://awesome-repositories.com/f/data-databases/database-record-management/record-updates/record-creations-and-updates/client-generated-keys.md) — Generating full unique ids in the browser or on a device before saving, so a complete record can be inserted without waiting for the database to assign a key.
- [Distributed Primary Key Generation](https://awesome-repositories.com/f/data-databases/entity-modeling/primary-keys/distributed-primary-key-generation.md) — Produces ids that increase roughly with creation time so they work as sortable database primary keys with efficient indexes.

### Software Engineering & Architecture

- [Identifier Collision Prevention](https://awesome-repositories.com/f/software-engineering-architecture/identifier-collision-prevention.md) — Mixes a per-client fingerprint into each id so separate servers and browsers rarely produce matching values without coordination. ([source](https://github.com/paralleldrive/cuid/blob/master/README.md))
- [Local Synchronous ID Generation](https://awesome-repositories.com/f/software-engineering-architecture/local-synchronous-id-generation.md) — Computes ids synchronously on the calling machine with no database or network round trip, so clients can build full records before inserting.
- [Machine Fingerprint Segments](https://awesome-repositories.com/f/software-engineering-architecture/machine-fingerprint-segments.md) — Derives a machine-specific id segment from process and host details or browser traits so ids from separate machines rarely match.
- [Time-Sorted Identifier Libraries](https://awesome-repositories.com/f/software-engineering-architecture/time-sorted-identifier-libraries.md) — Uses an id scheme whose values increase roughly with creation time, improving database primary key ordering and lookup performance.

### Programming Languages & Runtimes

- [Browser and Server Runtime Targets](https://awesome-repositories.com/f/programming-languages-runtimes/browser-and-server-runtime-targets.md) — Ships a Node module and a separately minified browser bundle from the same source so the generator runs on either side.

### Web Development

- [Short Random Slugs](https://awesome-repositories.com/f/web-development/url-generators/slug-generators/short-random-slugs.md) — Offers a slug function returning seven to ten characters for disambiguating URLs, trading uniqueness and unguessability for brevity.
- [URL Identifiers](https://awesome-repositories.com/f/web-development/url-identifiers.md) — Offers a slug function returning seven to ten characters for disambiguating URLs, trading uniqueness and unguessability for brevity. ([source](https://github.com/paralleldrive/cuid/blob/master/README.md))
