Physical quantities have dimensions. Meters measure length. Seconds measure time. You can't add them — it's physically meaningless. Yet most programs represent both as plain number, and the compiler can't help you catch the mistake.
unitsafe encodes dimensional information into TypeScript's type system. The compiler rejects invalid operations at build time, and the library provides ergonomic unit conversions with runtime metadata for display and formatting.
Why not just use plain numbers with naming conventions?
distanceMeters + timeSeconds compiles and runs silently, producing garbage
Naming conventions don't compose: what type should distanceMeters / timeSeconds have?
Off-by-one scale errors (forgetting to convert km to m) are invisible until production
unitsafe gives you:
Compile-time errors for dimension mismatches (add/sub/compare)
Automatic dimension composition for multiply/divide (m/s, m^2, kg*m/s^2)
Type-safe conversions between compatible units (km <-> m, s <-> ms, C <-> F)
Branded types that prevent accidental mixing of raw numbers with quantities
Tiny runtime — each quantity is a 4-property object; no classes, no prototypes
If you like the idea of utility classes…
but don’t like 40KB+ frameworks, build steps, or config overload — this might be for you.
What makes it different?
~5KB gzipped
No build step
Modern CSS features (OKLCH, container queries, CSS variables)
Works with plain HTML
Designed for clarity, not abstraction
The philosophy is simple:
- Use modern CSS as much as possible.
- Keep utilities minimal.
- Let the browser do the heavy lifting.
What’s new in this update?
• Improved documentation structure
• Better internal navigation
• Expanded utilities reference
• More examples and usage patterns
• SEO improvements so developers can actually discover it
I’m aiming to make it:
– a serious lightweight alternative to larger utility frameworks
– a great fit for landing pages, SaaS apps, indie projects
– ideal for devs who prefer simplicity over heavy config
If you’re building:
• a side project
• a startup landing page
• a fast marketing site
• a minimal design system
…give it a look and let me know what you think.
Feedback, critiques, and pull requests are welcome
This is a simple image optimizer for Next.js projects. It uses the sharp library to optimize images and the next/image component to display them.
Supports next feature:
- srcset
- upload to Cloud Flare storage
- different images for mobile and desktop
unitsafe encodes dimensional information into TypeScript's type system. The compiler rejects invalid operations at build time, and the library provides ergonomic unit conversions with runtime metadata for display and formatting.
Why not just use plain numbers with naming conventions?
distanceMeters + timeSeconds compiles and runs silently, producing garbage Naming conventions don't compose: what type should distanceMeters / timeSeconds have? Off-by-one scale errors (forgetting to convert km to m) are invisible until production unitsafe gives you:
Compile-time errors for dimension mismatches (add/sub/compare) Automatic dimension composition for multiply/divide (m/s, m^2, kg*m/s^2) Type-safe conversions between compatible units (km <-> m, s <-> ms, C <-> F) Branded types that prevent accidental mixing of raw numbers with quantities Tiny runtime — each quantity is a 4-property object; no classes, no prototypes