{"id":27770697,"url":"https://github.com/mikaelvesavuori/mikroid","last_synced_at":"2026-02-24T10:04:18.645Z","repository":{"id":284690712,"uuid":"955750540","full_name":"mikaelvesavuori/mikroid","owner":"mikaelvesavuori","description":"A lightweight, customizable ID generator with zero dependencies.","archived":false,"fork":false,"pushed_at":"2025-03-27T06:30:27.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-18T11:33:12.026Z","etag":null,"topics":["id","id-generator","security"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mikaelvesavuori.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"mikaelvesavuori"}},"created_at":"2025-03-27T06:17:49.000Z","updated_at":"2025-03-27T06:30:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"0f18ac8a-c0a2-4e33-b9f2-0aef6f4d0de0","html_url":"https://github.com/mikaelvesavuori/mikroid","commit_stats":null,"previous_names":["mikaelvesavuori/mikroid"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/mikaelvesavuori/mikroid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaelvesavuori%2Fmikroid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaelvesavuori%2Fmikroid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaelvesavuori%2Fmikroid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaelvesavuori%2Fmikroid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mikaelvesavuori","download_url":"https://codeload.github.com/mikaelvesavuori/mikroid/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mikaelvesavuori%2Fmikroid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29779262,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["id","id-generator","security"],"created_at":"2025-04-29T21:14:16.876Z","updated_at":"2026-02-24T10:04:18.630Z","avatar_url":"https://github.com/mikaelvesavuori.png","language":"TypeScript","funding_links":["https://github.com/sponsors/mikaelvesavuori"],"categories":[],"sub_categories":[],"readme":"# MikroID\n\n**A lightweight, customizable ID generator with zero dependencies**.\n\n[![npm version](https://img.shields.io/npm/v/mikroid.svg)](https://www.npmjs.com/package/mikroid)\n\n[![bundle size](https://img.shields.io/bundlephobia/minzip/mikroid)](https://bundlephobia.com/package/mikroid)\n\n![Build Status](https://github.com/mikaelvesavuori/mikroid/workflows/main/badge.svg)\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n---\n\nMikroID generates unique, customizable identifiers for your applications with cryptographically secure randomness. It's tiny (\u003c 1KB minified and gzipped), has zero dependencies, and supports a more random (and more economical format) than UUID v4 and NanoID (using `extended` character set). Also includes box-ready alphanumeric and hex formats for such use-cases.\n\n- **Secure**: Uses crypto-secure randomness\n- **Lightweight**: Less than 1KB minified and gzipped\n- **Zero dependencies**: No external libraries required\n- **Customizable**: Multiple ID styles and configurations\n- **URL-safe option**: Generate IDs safe for URLs\n- **TypeScript support**: Full type definitions included\n- **Reusable configurations**: Create and reuse custom ID formats\n\n## Installation\n\n```bash\nnpm install mikroid -S\n```\n\n## Usage\n\n### Quick Start\n\n```typescript\nimport { MikroID } from 'mikroid';\n\n// Create a new instance\nconst mikroid = new MikroID();\n\n// Generate a default ID (16 chars, extended character set style with URL-safe chars)\nconst id = mikroid.create();\n// =\u003e \"FgH5_xT~1b3wK.7p\"\n\n// Generate a shorter ID\nconst shortId = mikroid.create(8);\n// =\u003e \"j4Kw~m1.\"\n\n// Generate an alphanumeric ID\nconst alphaId = mikroid.create(12, 'alphanumeric');\n// =\u003e \"a7Bz9X3KpL2q\"\n\n// Generate a hex ID in lowercase\nconst alphaId = mikroid.create(16, 'hex', true);\n// =\u003e \"69ae1f9de761cebf\"\n\n// Generate a lowercase-only ID\nconst lowerId = mikroid.create(10, 'extended', true);\n// =\u003e \"b3k_p7~r9w\"\n\n// Generate a non-URL-safe ID with special characters\nconst specialId = mikroid.create(12, 'extended', false, false);\n// =\u003e \"Ab3$K~p+r9w:\"\n```\n\n### Custom configurations\n\n```typescript\nimport { MikroID } from 'mikroid';\n\nconst mikroid = new MikroID();\n\n// Add a custom configuration\nmikroid.add({\n  name: 'user-id',\n  length: 10,\n  style: 'alphanumeric',\n  onlyLowerCase: true\n});\n\n// Generate IDs using this configuration\nconst userId = mikroid.custom('user-id');\n// =\u003e \"a7b3k9p7r9\"\n\n// Add another configuration\nmikroid.add({\n  name: 'session-id',\n  length: 32,\n  style: 'extended',\n  urlSafe: true\n});\n\n// Generate session IDs\nconst sessionId = mikroid.custom('session-id');\n// =\u003e \"KwM1p3Tx_r.7B~gL5fZ9jH2qN8vD6-yA\"\n```\n\n### Pre-configured instance\n\n```typescript\nimport { MikroID } from 'mikroid';\n\n// Create with pre-configured options\nconst mikroid = new MikroID({\n  'short-id': {\n    name: 'short-id',\n    length: 8,\n    style: 'alphanumeric',\n    onlyLowerCase: false\n  },\n  'api-key': {\n    name: 'api-key',\n    length: 24,\n    style: 'extended',\n    urlSafe: true\n  }\n});\n\n// Use pre-configured options\nconst shortId = mikroid.custom('short-id');\nconst apiKey = mikroid.custom('api-key');\n```\n\n## Character sets\n\nMikroID uses the following character sets based on the configuration:\n\n### Alphanumeric\n\n- `onlyLowerCase: false`: A-Z, a-z, 0-9\n- `onlyLowerCase: true`: a-z, 0-9\n\n### Extended\n\n- `urlSafe: true`, `onlyLowerCase: false`: A-Z, a-z, 0-9, -._~\n- `urlSafe: true`, `onlyLowerCase: true`: a-z, 0-9, -._~\n- `urlSafe: false`, `onlyLowerCase: false`: A-Z, a-z, 0-9, -._~!$()*+,;=:\n- `urlSafe: false`, `onlyLowerCase: true`: a-z, 0-9, -._~!$()*+,;=:\n\n### Hex\n\n- `onlyLowerCase: false`: A-F, a-f, 0-9\n- `onlyLowerCase: true`: a-f, 0-9\n\n## API Reference\n\n### MikroID Class\n\n#### Constructor\n\n```typescript\nconstructor(options?: MikroIDOptions)\n```\n\nCreates a new MikroID instance with optional pre-configured options.\n\n#### Methods\n\n##### create\n\n```typescript\ncreate(length?: number, style?: IdStyle, onlyLowerCase?: boolean, urlSafe?: boolean): string\n```\n\nGenerates a new ID with the specified parameters.\n\n- `length` (optional): Length of the generated ID. Default: 16\n- `style` (optional): Style of the ID ('alphanumeric', 'hex', or 'extended'). Default: 'extended'\n- `onlyLowerCase` (optional): Whether to use only lowercase letters. Default: false\n- `urlSafe` (optional): Whether to use only URL-safe characters. Default: true\n\n##### add\n\n```typescript\nadd(config: IdConfigurationOptions): void\n```\n\nAdds a new ID configuration to the options collection.\n\n- `config`: Configuration object with at least the `name` property\n\n##### remove\n\n```typescript\nremove(config: IdConfiguration): void\n```\n\nRemoves an existing ID configuration from the options collection.\n\n- `config`: Configuration object with at least the `name` property\n\n##### custom\n\n```typescript\ncustom(name: string): string\n```\n\nCreates a new ID using a named configuration.\n\n- `name`: Name of the configuration to use\n\n### Types\n\nAll types are exported.\n\n```typescript\ntype IdStyle = 'alphanumeric' | 'extended';\n\ntype IdConfiguration = {\n  name: string;\n  length: number;\n  onlyLowerCase: boolean;\n  style?: IdStyle;\n  urlSafe?: boolean;\n};\n\ntype IdConfigurationOptions = Partial\u003cIdConfiguration\u003e;\n\ntype MikroIDOptions = {\n  [name: string]: IdConfiguration;\n};\n```\n\n## Security\n\nMikroID uses cryptographically secure random generation via the Node.js `crypto` module.\n\n## Comparison with similar libraries\n\n| Feature                        | MikroID | nanoid | uuid (v4) |\n|--------------------------------|---------|--------|-----------|\n| Size (gzip)                    | \u003c1KB    | \u003c1KB   | \u003c1KB      |\n| Dependencies                   | 0       | 0      | 0         |\n| Secure                         | ✓       | ✓      | ✓         |\n| URL-safe (default or optional) | ✓       | ✓      | ✓         |\n| Alphabet options               | ✓       | ✓      | ✗         |\n| Named configs                  | ✓       | ✗      | ✗         |\n\n## License\n\nMIT. See the `LICENSE` file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikaelvesavuori%2Fmikroid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikaelvesavuori%2Fmikroid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikaelvesavuori%2Fmikroid/lists"}