Strapi plugin logo for Auto NanoID

Auto NanoID

Automatically generate a NanoID for your components

Tests

Strapi Auto NanoID Plugin

The Strapi Auto NanoID Plugin is a custom plugin for Strapi that automatically generates a unique NanoID for your content.

Installation

To install the Strapi Auto NanoID Plugin, simply run one of the following command:

1pnpm add strapi-auto-nanoid
1npm install strapi-auto-nanoid
1yarn add strapi-auto-nanoid

Usage

Once the plugin is installed, you can add a new custom type to your Strapi content types, no configuration needed. The custom type uses the Strapi UID structure, ensuring that each NanoID generated is unique.

You can create new records via the Admin panel, API or GraphQL, and the plugin will automatically generate a NanoID for each new record created.

Example

Here's an example of how to use the Strapi Auto NanoID Plugin:

  1. Install the plugin using npm install strapi-auto-nanoid
  2. Create a new Strapi model with the custom type autoNanoID, like this:
1module.exports = {
2  attributes: {
3    title: {
4      type: 'string',
5      required: true,
6    },
7    uid: {
8      type: "customField",
9      customField: "plugin::field-nanoid.nanoid"
10    },
11  },
12};
  1. When you create a new record in this model via the Strapi API or GraphQL, the plugin will automatically generate a unique NanoID for the uid field.

That's it! With the Strapi Auto NanoID Plugin, you can easily add NanoID to your Strapi content without having to worry about generating them yourself.

License

This plugin is licensed under the MIT License. See the LICENSE file for more information.

This plugin is a fork of strapi-auto-uuid based on the work by Cringe Studio: https://github.com/Cringe-Studio/strapi-auto-uuid

Install now

npm install strapi-auto-nanoid

STATS

No GitHub star yet26 weekly downloads

Last updated

450 days ago

Strapi Version

4.9.2 and above

Author

github profile image for Timothy Choi
Timothy Choi

Useful links

Create your own plugin

Check out the available plugin resources that will help you to develop your plugin or provider and get it listed on the marketplace.