Introduction
Zero-dependency input masks for React Hook Form, with Turkish validators, type safety and server support.
The form keeps the raw value (5551234567); the input shows the mask ((555) 123 45 67). register rules, reset, setValue, watch and resolvers keep working.
Getting started
$ pnpm add @virastack/maskForm value: -
Display: -
Form value: -
Display: -
Form value: -
Display: -
Try every preset on the examples page. On v1? Read the upgrade guide.
Why ViraStack Mask?
- Built for React Hook Form: the form is the single source of truth; the hook keeps no value state.
- Turkey ready: TCKN, VKN, Turkish IBAN and phone, and TRY that keeps kuruş.
- Type-safe: field names,
fromand rules are checked against your form type; a typo is a compile error. - On the server too: the same schema parses and validates in a Server Action with
@virastack/mask/server. - Stays out of the way: not a UI package; works with shadcn/ui, Radix or a plain input.
Comparison
It doesn't compete with imask or Maskito on engine power; the difference is React Hook Form, Turkey and the server.
| Feature | ViraStack Mask | react-imask | Maskito |
|---|---|---|---|
| Designed for React Hook Form (register rules, reset, setValue) | Yes | Partial or manual | Partial or manual |
| Pattern masks, custom tokens, optional parts, dynamic masks | Yes | Yes | Partial or manual |
| Number and date (min/max) | Yes | Yes | Yes |
| Card type detection | Yes | No | No |
| Luhn algorithm | Yes | No | No |
| TCKN, VKN, Turkish IBAN validation | Yes | No | No |
| Per-country phone formatting | Partial or manual | Partial or manual | Yes |
| Parsing and validation on the server | Yes | Partial or manual | Partial or manual |
| Vue, Angular | No | Yes | Yes |
| Range, Enum, Pipe blocks | No | Yes | Partial or manual |
| Runtime dependencies | - | imask, prop-types | - |
| Size (same form, min+gzip) | 8.3 KB | 17.1 KB | 10.6 KB |
| Latest release | 2.0.0Oct 2026 | 7.6.1May 2024 | 5.6.1Oct 2026 |
yes · partial or manual · no. Checked on 29 October 2026 against the npm packages (@virastack/mask 2.0.0, react-imask 7.6.1, @maskito/react 5.6.1).
How size was measured: The same form was written with each library: Turkish phone, card number, expiry, CVV, TRY amount and a date no later than today, with values written to React Hook Form. Each was built with esbuild in production mode, minified and tree-shaken. The number is the gzip size of the difference over the same form built without a mask library, so React and React Hook Form, present on both sides, are not counted. Mask’s card preset also includes card type detection and the Luhn algorithm; the other two do not.
Peer dependencies
react≥ 18.2 (React 19 recommended)react-hook-form≥ 7.55
No runtime dependencies. The whole package is ~10 KB (min + brotli). ViraStack Start CLI can add it for you.
Scope
- useViraMask(): schema, linked fields and React Hook Form compatibility
- Custom mask: pattern syntax, number, currency, date and
definePreset - Validation and the server
- Helpers and types
- Examples for every preset