DEV Community

Cover image for Sernam: The Easy Way to Generate Unique Usernames with Javascript and NodeJS
Afsarul Islam Meraj
Afsarul Islam Meraj

Posted on • Updated on

Sernam: The Easy Way to Generate Unique Usernames with Javascript and NodeJS

Are you tired of coming up with usernames for your users or yourself? Do you want a quick and easy way to generate unique usernames without having to spend a lot of time thinking about it? Look no further than Sernam, the username generator for Javascript and NodeJS.


Sernam is a lightweight and easy-to-use package that can generate single or multiple usernames from a given name. All you have to do is import it and pass in the name as a parameter. Sernam will then generate a unique username based on that name, and you can choose whether to include symbols and numbers in the generated username.


To get started with Sernam, simply install it using npm:

$ npm i sernam
Enter fullscreen mode Exit fullscreen mode

Once installed, you can import and initialize Sernam in ES6:

import sernam from "sernam"
const options = {
  symbols: true,
  numbers: true,
}
const sn = sernam(options)
Enter fullscreen mode Exit fullscreen mode

Or in CommonJS:

import("sernam").then(({ default: sernam }) => {
  const options = {
    symbols: true,
    numbers: true,
  }
  const sn = sernam(options)
})
Enter fullscreen mode Exit fullscreen mode

Sernam accepts an options object with two boolean properties: symbols and numbers. If you don't pass any options object, the generated usernames will not include symbols and numbers by default.


To generate a single username, use the .generateOne() function:

let username = sn.generateOne("Firstname Lastname")
Enter fullscreen mode Exit fullscreen mode

To generate multiple usernames, use the .generateMany() function:

let usernames = sn.generateMany("Firstname Lastname", 10)
Enter fullscreen mode Exit fullscreen mode

In both cases, Sernam will generate unique usernames based on the given name.


Sernam is licensed under the MIT license, which means you can use it for any purpose, commercial or non-commercial, as long as you include the license in your project.

In conclusion, if you're looking for a quick and easy way to generate unique usernames, Sernam is the way to go. With its simple API and customizable options, Sernam can save you time and hassle when it comes to username generation.

Top comments (0)