Lunar Kit LogoLunar Kit

CLI

Use the Lunar Kit CLI to manage components and modules in your project

The Lunar Kit CLI (lunar) helps you add and manage components, modules, and localization in your React Native project.

Installation

# Global installation (recommended)
pnpm add -g @lunar-kit/cli
 
# Or use dlx without installing
pnpm dlx @lunar-kit/cli [command]

Available Commands

CommandDescription
lunar initInitialize Lunar Kit in your project
lunar addAdd a UI component or locale to your project
lunar generate (g)Generate a Lunar Kit element (module, component, etc.)

init

Initialize Lunar Kit in your existing React Native project.

lunar init

What it does

  1. Creates src/components/ui directory
  2. Sets up lib/utils.ts with helper functions
  3. Installs required dependencies (clsx, tailwind-merge)
  4. Creates kit.config.json configuration file

Interactive Prompts

šŸŒ™ Initializing Lunar Kit...

? Would you like to use TypeScript? › Yes
? Which package manager do you use? › pnpm / npm / yarn / bun

add

Add components from the Lunar Kit registry or setup localization entries.

lunar add <component>

UI Components

# Add a single component
lunar add button
 
# Add multiple components
lunar add button card dialog input
 
# Add all available components
lunar add --all

Localization

Add a translation entry to all locale files:

lunar add locale

generate (gen, g)

Generate a Lunar Kit element using schematics. This powerful command allows you to scaffold modules, components, stores, hooks, and localization files.

lunar generate [options] <schematic> [path]
# or
lunar g [options] <schematic> [path]

Available Schematics

Module

SchematicAliasDescription
modmodGenerate a module
tabstabsGenerate a tabs module
# Generate a module
lunar g mod auth/login
 
# Generate a tabs module
lunar g tabs shop

Module-Scoped

Generate elements within a specific module:

SchematicAliasDescription
mod:viewmod:viGenerate a view in module
mod:componentmod:coGenerate a component in module
mod:storemod:stGenerate a store in module
mod:hookmod:hoGenerate a hook in module
# Generate a view inside a module
lunar g mod:vi auth/login-screen
 
# Generate a component inside a module
lunar g mod:co auth/LoginForm

Global

Create elements in the global src/ directory (e.g. src/components/, src/hooks/, src/stores/):

SchematicAliasDescription
componentcoGenerate a global component
hookhoGenerate a global hook
storestGenerate a global store
# Create a global component
lunar g component Header
 
# Create a global hook
lunar g hook useAuth

Localization

Manage translation files:

SchematicAliasDescription
localeloGenerate a new locale file
# Generate a new locale file (e.g., zh, id)
lunar g locale zh

Configuration

Lunar Kit stores configuration in kit.config.json at the root of your project:

{
"typescript": true,
"componentsPath": "src/components",
"packageManager": "pnpm"
}

Options

OptionDefaultDescription
typescripttrueUse TypeScript for components
componentsPathsrc/componentsWhere to store components
packageManagerpnpmPackage manager to use

Workflow Examples

Starting a New Feature

# 1. Create a module for the feature
lunar g mod checkout
 
# 2. Add required UI components
lunar add button card input form
 
# 3. Create custom components inside the module
lunar g mod:co checkout CheckoutForm
lunar g mod:co checkout OrderSummary

Adding Components to Existing Project

# 1. Initialize Lunar Kit
lunar init
 
# 2. Add commonly used components
lunar add button text card input
 
# 3. Add more as needed
lunar add dialog bottom-sheet tabs

Output Examples

When using the generate schema for modules and components, the CLI will log its progress and actions:

$ lunar g mod:vi auth/login-screen
 
šŸŒ™ Generating view auth/login-screen...
āœ“ Created view: src/modules/auth/screens/login-screen.tsx
āœ“ Created view index: src/modules/auth/screens/index.ts
āœ“ Updated module exports: src/modules/auth/screens/index.ts

Now explore the Components documentation to learn how to use each component!

On this page