> ## Documentation Index
> Fetch the complete documentation index at: https://villagesql.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# vsql_nanoid extension for MySQL

> The vsql_nanoid community extension generates short URL-safe random identifiers in MySQL, 21 characters by default, with a configurable length and alphabet.

A Nano ID is 21 characters where a UUID is 36, drawn from an alphabet that is
safe in a URL without escaping. `vsql_nanoid` generates them in SQL, so a
public-facing identifier can be produced at insert time rather than in your
application.

| | |
| - | - |
| **Maintainer** | [Anurag Ojha](https://github.com/intojhanurag) |
| **Source and documentation** | [intojhanurag/vsql-nanoid](https://github.com/intojhanurag/vsql-nanoid) |
| **License** | GPL-2.0 |

> [!NOTE]
>
> A third party writes and maintains this extension. VillageSQL does not build,
> test, or ship it, and the description below follows the maintainer's own
> documentation. Read that documentation before you rely on it.

## Install

Build it from the repository against a VillageSQL build tree (`VillageSQL_BUILD_DIR`), copy the `.veb` file into the server's `veb_dir`, then install it. It needs OpenSSL
for its random source.

```sql theme={null}
INSTALL EXTENSION vsql_nanoid;
```

## What it adds

| Function | Returns | What it does |
| - | - | - |
| `nanoid()` | text | A 21-character identifier from the default alphabet, `A-Za-z0-9_-` |
| `nanoid_with(size)` | text | The same, at a length you choose |
| `nanoid_with(size, alphabet)` | text | The same, from an alphabet you choose |

## See also

* [UUIDs in MySQL](https://villagesql.com/docs/guides/uuids.md) — the other way to generate an opaque identifier
* [Primary key strategies](https://villagesql.com/docs/guides/primary-key-strategies.md) — what a random key costs on an InnoDB index
* [Available extensions](https://villagesql.com/docs/mysql-8.4/0.0.6/extensions.md) — the full catalog
* [intojhanurag/vsql-nanoid](https://github.com/intojhanurag/vsql-nanoid) — source, examples, and the known limitations


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.