valibot
nanoid
valibot | nanoid | |
---|---|---|
7 | 84 | |
5,379 | 23,717 | |
- | - | |
9.9 | 8.4 | |
3 days ago | 4 days ago | |
TypeScript | JavaScript | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
valibot
-
Using Valibot for Recursive Schema Validation
What if you use a schema library, like Zod or Valibot? The schema has been built on value-level, and you cannot assign the variant to its property inside the declaration.
-
Next.js and Bunny CDN: Complete Guide to Image Uploading with Server Actions
I'll use Valibot library, which is a pretty new and cool library for schema validation, similar to Zod.
-
Effortlessly Generate Structured Information with Ollama, Zod, and ModelFusion
The ModelFusion zodSchema function wraps the Zod object definition. This is necessary because ModelFusion supports Zod and unchecked JSON schemas and is adaptable to other schema validation libraries such as Valibot.
-
Hacktoberfest Week 2 PR
There was already existing validation in place for the question form page using Valibot, so I only needed to change two lines of code. I imported includes in addition to the other Valibot functions, and I also added an a new line of validation using the includes function to ensure the string has at least one space (If it does not the corresponding error message will be displayed). I had never used Valibot before, but it was easy to learn by looking at the web documentation as well as the existing code. See screenshots of my fix in my PR.
-
Database Review: Top Five Missing Features from Database APIs
Valibot (good for types and constraints)
-
Angular vs. React vs. Vue.js: Comparing performance
Valibot: A lightweight schema declaration and validation library. Its bundle size is less than 1kb
- Valibot, a <1kb Alternative to Zod
nanoid
-
Mastering Real-Time Collaboration: Building Figma and Miro-Inspired Features with Supabase
CURRENT_CLIENT_ID is the random unique string Id generated by nanoid that gets generated whenever the client is opened on the brower’s tab.
-
Next.js and Bunny CDN: Complete Guide to Image Uploading with Server Actions
Last thing left is to use our new upload function in our server action. Since I like to upload images in single format and have some more control over them, I will additionally use sharp library. For file name, I'll generate some random string using nanoid:
- Nano ID Collision Calculator
-
Why we chose Bun
Our API is in node. And God, how I suffered to import nanoid in an esmodule project. I had to vendor it, since using a previous version was not ideal. With bun, we can no longer worry about that. Just import what you need and done.
-
UUIDv7 is coming in PostgreSQL 17
No thread about UUID is complete without a plug for NanoID! https://github.com/ai/nanoid/blob/main/README.md
-
Building a File Storage With Next.js, PostgreSQL, and Minio S3
Generate a unique file name using the nanoid library.
-
Building a Multi-Tenant App with FastAPI, SQLModel, and PropelAuth
The syntax should read similar to SQL itself. We’re using a Python port of nanoid to generate our IDs. There’s only one thing missing… how do we actually create the table?
-
You Don't Need UUID
I usually go for Nano Id for new projects https://github.com/ai/nanoid
-
Enhance Your Web Apps: Best JS Libraries 🔧
Nano ID
-
Analyzing New Unique Identifier Formats (UUIDv6, UUIDv7, and UUIDv8) (2022)
In another comment I mentioned I use nanoid in my projects now. It has a default space of 64^21 and has an a page where you can play with key lengths and alphabet sizes and see the probability of collisions :
https://zelark.github.io/nano-id-cc/
At the default 64 character alphabet with a 21 character key length it would take ~41 million years in order to have a 1% probability of at least one collision if you generated 1000 ids per second.
What are some alternatives?
react-hook-form - 📋 React Hooks for form state management and validation (Web + React Native)
snowflake - Snowflake is a network service for generating unique ID numbers at high scale with some simple guarantees.
vuelidate - Simple, lightweight model-based validation for Vue.js
ksuid - K-Sortable Globally Unique IDs
zoxy - A small type-safe object proxy around Zod to help you stay safe after your data is loaded while continuing to edit them.
typedorm - Strongly typed ORM for DynamoDB - Built with the single-table-design pattern in mind.
Hasura - Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
pg_random_id - Provides pseudo-random IDs in Postgresql databases
Vue.js - This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core
jest - Delightful JavaScript Testing.
zustand - 🐻 Bear necessities for state management in React
Numeral-js - A javascript library for formatting and manipulating numbers.