{"id":43191,"library":"mongodb-short-id","title":"MongoDB Short ID","description":"Convert MongoDB ObjectIDs to shorter URL-friendly strings and reverse them back. Version 0.3.3 is the latest stable release, last updated in 2014. It uses base64 encoding to produce compact IDs. Differentiators: simple API, supports both string and ObjectID conversions. However, it is an unmaintained package with no updates since its release, and it depends on the deprecated MongoDB native driver's ObjectID. Consider using uuid-based approaches or modern MongoDB drivers for active support.","status":"deprecated","version":"0.3.3","language":"javascript","source_language":"en","source_url":"https://github.com/TheHippo/mongodb-short-id","tags":["javascript","MongoDB","id","Mongo"],"install":[{"cmd":"npm install mongodb-short-id","lang":"bash","label":"npm"},{"cmd":"yarn add mongodb-short-id","lang":"bash","label":"yarn"},{"cmd":"pnpm add mongodb-short-id","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Uses ObjectID from the core MongoDB driver","package":"mongodb","optional":false}],"imports":[{"note":"Package uses CommonJS; no ESM exports. Use require() or wrap with createRequire.","wrong":"import shortID from 'mongodb-short-id';","symbol":"default","correct":"const shortID = require('mongodb-short-id');"},{"note":"Expects a hex string (24 chars), not an ObjectID instance.","wrong":"shortID.longToShort(new ObjectID('...'));","symbol":"longToShort","correct":"shortID.longToShort('507f1f77bcf86cd799439011');"},{"note":"Returns a MongoDB ObjectID instance (requires mongodb package).","wrong":"shortID.shortToObjectID(shortID);","symbol":"shortToObjectID","correct":"shortID.shortToObjectID('UH8fd7z4bNeZQ5AR');"}],"quickstart":{"code":"const shortID = require('mongodb-short-id');\nconst longId = '507f1f77bcf86cd799439011';\nconst short = shortID.longToShort(longId);\nconsole.log(short); // => 'UH8fd7z4bNeZQ5AR'\nconst back = shortID.shortToLong(short);\nconsole.log(back); // => '507f1f77bcf86cd799439011'\nconst obj = shortID.shortToObjectID(short);\nconsole.log(obj instanceof require('mongodb').ObjectID); // true","lang":"javascript","description":"Shows basic conversion: long hex string to short URL-safe string and back, plus ObjectID conversion."},"warnings":[{"fix":"Consider using a modern alternative like generating UUIDs or using nanoid for short IDs.","message":"Package has not been updated since 2014 and depends on an outdated mongodb driver version.","severity":"deprecated","affected_versions":">=0"},{"fix":"Convert ObjectID to hex string first: objectID.toHexString().","message":"longToShort expects a 24-character hex string; passing an ObjectID instance will cause errors.","severity":"gotcha","affected_versions":">=0"}],"env_vars":null,"search_vec":"'0.3.3':18 '2014':27 'activ':79 'api':38 'approach':73 'back':16 'base':72 'base64':30 'compact':34 'consid':68 'convers':44 'convert':4 'depend':59 'deprec':62 'differenti':36 'driver':65,77 'encod':31 'friend':11 'howev':45 'id':3,35,83 'javascript':81 'last':24 'latest':21 'modern':75 'mongo':84 'mongodb':1,5,63,76,82 'nativ':64 'objectid':6,43,67 'packag':50 'produc':33 'releas':23,56 'revers':14 'short':2 'shorter':8 'simpl':37 'sinc':54 'stabl':22 'string':12,41 'support':39,80 'unmaintain':49 'updat':25,53 'url':10 'url-friend':9 'use':29,69 'uuid':71 'uuid-bas':70 'version':17","created_at":"2026-06-05T16:58:37.157765+00:00","updated_at":"2026-06-05T16:58:37.157765+00:00","problems":[{"fix":"Use `const shortID = require('mongodb-short-id');` or use dynamic import with createRequire.","cause":"Using ESM import syntax on a CommonJS module without default export.","error":"TypeError: shortID.longToShort is not a function"},{"fix":"Run `npm install mongodb` to install the core MongoDB driver.","cause":"The package requires 'mongodb' as a peer dependency but it's not installed.","error":"Error: Cannot find module 'mongodb'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/TheHippo/mongodb-short-id#readme","github":"https://github.com/TheHippo/mongodb-short-id","docs":null,"changelog":null,"pypi":null,"npm":"mongodb-short-id","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-05","next_check":"2026-09-03","install_tag":null}}