Build Elevate

Utilities

Shared utility functions, schemas, and types for the monorepo.

Overview

@workspace/utils provides shared utility functions, schemas, and types for the monorepo, including:

  • Helper functions for strings, numbers, and dates
  • Validation schemas built with Zod
  • Shared TypeScript types
  • Date formatting powered by date-fns

Usage

Import and use utilities in your apps:

import { capitalize, truncate } from "@workspace/utils/helpers";
import { emailSchema, signInSchema } from "@workspace/utils/schemas";
import type { AuthUser } from "@workspace/utils/types";

Features

  • Helper Functions: String manipulation, number operations, date formatting
  • Validation Schemas: Pre-built Zod schemas for authentication and common data
  • Type Definitions: Shared TypeScript types for consistency across apps
  • Modular Exports: Import only what you need with granular exports

Available Exports

Helpers (@workspace/utils/helpers)

  • String: capitalize, truncate, isEmpty
  • Number: clamp, round
  • Date: formatDate, formatDistanceToNow, formatDuration, intervalToDuration

Schemas (@workspace/utils/schemas)

  • Auth: emailSchema, passwordSchema, nameSchema, signInSchema, signUpSchema

Types (@workspace/utils/types)

  • Auth types: Shared authentication type definitions

Example

import { capitalize, truncate } from "@workspace/utils/helpers";
import { emailSchema } from "@workspace/utils/schemas";

// String helpers
const title = capitalize("hello world"); // "Hello world"
const short = truncate("Very long text...", 10); // "Very long…"

// Validation
const result = emailSchema.safeParse("user@example.com");
if (result.success) {
  console.log("Valid email:", result.data);
}

See the source in packages/utils/src/ for more utilities and details.

On this page