PHPackages                             fanmade/laravel-nanoid - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. fanmade/laravel-nanoid

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

fanmade/laravel-nanoid
======================

A small package to add Nano IDs to Laravel

1.1.0(1y ago)012.5k↓36.7%1MITPHPPHP ^8.1CI failing

Since May 14Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Fanmade/laravel-nanoid)[ Packagist](https://packagist.org/packages/fanmade/laravel-nanoid)[ RSS](/packages/fanmade-laravel-nanoid/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (2)Dependencies (7)Versions (3)Used By (0)

Laravel Nano ID
===============

[](#laravel-nano-id)

[![Laravel Nano ID Logo](/art/laravel-nano-id-logo.png)](/art/laravel-nano-id-logo.png)

Introduction
------------

[](#introduction)

A simple package to generate Nano IDs in Laravel.

What is a Nano ID?
==================

[](#what-is-a-nano-id)

A Nano ID is a URL-friendly, unique string ID.
It is similar to UUIDs, but shorter and more readable.
Nano IDs are 21 characters long by default and can be customized to be longer or shorter.

- Read more on Medium: [Nano ID: A Tiny, Secure URL-friendly Unique String ID Generator](https://medium.com/@gaspm/nano-id-popular-secure-and-url-friendly-unique-identifiers-1fa86c9fdf7c)
- Or on GitHub: [Nano ID](https://github.com/ai/nanoid)

Table of Contents
=================

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Configuration](#configuration)
- [Testing](#testing)
- [Alternatives (and inspirations)](#alternatives-and-inspirations)

Features
--------

[](#features)

- A facade to generate Nano IDs
- A helper function to use as alternative to the facade
- Configuration options to customize the defaults for your Nano IDs
    - Prefix
    - Suffix
    - Alphabet
    - Size
    - Random string generator
    - More to come
- Easily extensible with custom validation rules (like uniqueness or swear word checks)

Requirements
------------

[](#requirements)

- PHP &gt;= 8.0

Installation
------------

[](#installation)

```
composer require fanmade/laravel-nanoid
```

Usage
-----

[](#usage)

```
use Fanmade\NanoId\Facades\NanoID;

echo NanoID::generate(); // Returns a Nano ID

echo NanoID::generate(length: 10); // Returns a Nano ID with a length of 10

echo NanoID::generate(length: 10, prefix: 'prefix_'); // Returns a Nano ID with a length of 10 and a prefix of 'prefix_'

echo NanoID::generate(suffix: '_suffix'); // Returns a Nano ID with a suffix of '_suffix'

echo NanoID::generate(alphabet: '0123456789'); // Returns a Nano ID only containing numbers

echo nano_id(); // The helper function accepts the same parameters as the generate method
```

Configuration
-------------

[](#configuration)

Publish the configuration file

```
php artisan vendor:publish --tag=nanoid-config
```

OptionDescriptionDefault`prefix`An optional prefix which will be added to the Nano ID`''``suffix`An optional suffix which will be added to the Nano ID`''``alphabet`The alphabet to use for generating the Nano ID`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_`+
`abcdefghijklmnopqrstuvwxyz-``size`The default size/length of the Nano ID`21``generator`The generator class to use for generating random strings`\Fanmade\NanoId\Generator\HidehaloStringGenerator``include_prefix_in_length`Controls if the prefix is included or excluded in the size limitationtrue`include_suffix_in_length`Controls if the suffix is included or excluded in the size limitationtrueTesting
-------

[](#testing)

```
vendor/bin/pest
```

or

```
composer test
```

Alternatives (and inspirations)
-------------------------------

[](#alternatives-and-inspirations)

- [hidehalo/nanoid-php](https://github.com/hidehalo/nanoid-php) - The original Nano ID package for PHP. This is also used in the background of this package.
- [yondifon/laravel-nanoid](https://github.com/yondifon/laravel-nanoid) - More focused on adding the Nano IDs to the models.
- [ttbooking/laravel-nanoid](https://github.com/ttbooking/laravel-nanoid) - This one has more focus on extending the string helpers.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance42

Moderate activity, may be stable

Popularity27

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~307 days

Total

2

Last Release

474d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/03ee7b67b9a5fc7e28528dcd9756394b83f8923c6592fde5aaa43189d0022f7b?d=identicon)[Fanmade](/maintainers/Fanmade)

---

Top Contributors

[![Fanmade](https://avatars.githubusercontent.com/u/2896491?v=4)](https://github.com/Fanmade "Fanmade (24 commits)")[![erossdev](https://avatars.githubusercontent.com/u/78756041?v=4)](https://github.com/erossdev "erossdev (1 commits)")

---

Tags

laravelnanoidlaravel-nanoidnano-id

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fanmade-laravel-nanoid/health.svg)

```
[![Health](https://phpackages.com/badges/fanmade-laravel-nanoid/health.svg)](https://phpackages.com/packages/fanmade-laravel-nanoid)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.9k69.5k](/packages/grumpydictator-firefly-iii)[firefly-iii/data-importer

Firefly III Data Import Tool.

8035.8k](/packages/firefly-iii-data-importer)[markwalet/nova-modal-response

A Laravel Nova asset for Modal responses on an action.

17878.9k](/packages/markwalet-nova-modal-response)[ronasit/laravel-helpers

Provided helpers function and some helper class.

2085.6k31](/packages/ronasit-laravel-helpers)[team-nifty-gmbh/tall-datatables

Server-side rendered datatables for Laravel and Livewire

1320.9k4](/packages/team-nifty-gmbh-tall-datatables)[riipandi/laravel-optikey

Use UUID, Ulid, or nanoid as optional or primary key in Laravel.

429.3k](/packages/riipandi-laravel-optikey)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
