# Utils

> Generated reference (regen-owned; see [index.md](index.md)). Binds only under `primitives: nurix`.

Low-level utilities and shared types, each published as its own subpath under `@nurix/components/<subpath>`.

## cn

`cn(...inputs)` (from `utils`) — `clsx` + `tailwind-merge`; the class-merge used throughout the library. Same subpath also exports `isMobileDevice()` (UA-sniffing boolean, prefer `useIsMobile` in components).

```tsx
<div className={cn("rounded-md", isActive && "bg-primary", className)} />
```

## formatDate

`formatDate(date, opts?)` (from `format`) — Intl-based date formatting; returns `""` on a missing/invalid input instead of throwing. Defaults to `{ month: "long", day: "numeric", year: "numeric" }`, overridable via `opts`.

## generateId

`generateId(prefixOrOptions?, options?)` (from `id`) — nanoid-based alphanumeric ID; `{ length = 12, separator = "_" }`. Accepts a prefix key as the first argument (prepended with `separator`) or an options object directly.

## getErrorMessage

`getErrorMessage(err)` (from `handle-error`) — normalizes an unknown error into a display string: joins `ZodError` issue messages with newlines, passes through a plain `Error.message`, else a generic fallback.

## getStrictContext

`getStrictContext<T>(name?)` (from `get-strict-context`) — returns a `[Provider, useSafeContext]` pair; the hook throws (`useContext must be used within <name>`) when read outside its `Provider`, instead of silently returning `undefined`.

## composeRefs

`composeRefs(...refs)` / `useComposedRefs(...refs)` (from `compose-refs`) — merges multiple callback refs and `RefObject`s (including React 19 ref-cleanup returns) into one callback ref.

---

Two further subpaths are non-UI escape hatches, not composable concepts: `types` (a barrel of public component prop types — `InputProps`, `SelectProps`, `CellProps`, …) and `node-catalog` (runtime node definitions for the NuStack Plan engine — data, not UI).
