ui.* factory functions. You’ll learn the basics of state management, widget composition, and event handling.
Prerequisites
Before starting, make sure you have:- Node.js 18+ or Bun 1.3+ installed
- A terminal with 256-color or true-color support
Step 1: Scaffold a New Project
The fastest way to start is usingcreate-rezi:
- Select minimal template (or press Enter for the default)
- Wait for dependencies to install
Step 2: Understanding the Project Structure
The minimal template creates this structure:Step 3: Build a Counter App
Let’s modify the generated code to create a counter. Opensrc/types.ts and define your state:
src/types.ts
Step 4: Create the Reducer
Opensrc/helpers/state.ts and implement the state logic:
src/helpers/state.ts
Step 5: Create the View
Opensrc/screens/main-screen.ts and build your UI:
src/screens/main-screen.ts
Step 6: Wire Up the App
Opensrc/main.ts and connect everything:
src/main.ts
Step 7: Run Your App
- A count display with a badge
- Three buttons for increment, decrement, and reset
- Help text with keyboard shortcuts
- Theme cycling support
+— Increment-— DecrementR— ResetT— Cycle themesQ— Quit
Understanding the Code
State Management
Rezi uses a simple reducer pattern:- State type —
AppStatedefines what data your app holds - Actions —
AppActionunion defines all possible state changes - Reducer —
reduceAppState()applies actions to produce new state - Update —
app.update()triggers a state transition and re-render
Widget Composition
Widgets are composed using factory functions fromui.*:
ui.page()— Root container with padding and layoutui.header()— Title bar with subtitleui.panel()— Labeled content sectionui.button()— Interactive button with intent stylingui.callout()— Info/warning/error message box
p, gap, flex, etc.) and semantic props (variant, intent, etc.).
Event Handling
Events are handled via callbacks:- Widget callbacks —
onPress,onInput,onChange, etc. - Global keybindings —
app.keys()for keyboard shortcuts - Lifecycle hooks —
app.start(),app.stop(),app.dispose()
Using JSX (Optional)
You can also build the same counter with JSX:src/screens/main-screen.tsx
Next Steps
Explore Widgets
Browse the complete widget catalog
Learn Concepts
Understand Rezi’s architecture and patterns
Styling Guide
Master layout, theming, and design tokens
Example Templates
Explore advanced templates and patterns