remodel init
Initializes a new ReModel project. This command creates the models directory, a Providers component, installs @blue-functor/remodel, and writes a .remodel config file.
Usage
Interactive:
remodel
# then select "Initialize Project"Non-interactive:
remodel init --ts --platform react --dir ./src/modelsOptions
| Flag | Type | Default | Description |
|---|---|---|---|
--ts | boolean | true | Use TypeScript |
--js | boolean | false | Use JavaScript |
--platform <platform> | string | react | Target platform (react or react-native) |
--dir <directory> | string | auto-detect | Models directory path |
If --dir is not provided, the CLI looks for an existing models/, src/models/, or app/models/ directory. If none is found, it defaults to ./src/models.
What It Does
The init command performs four steps:
1. Creates the models directory and index file
- index.ts
import type { ModelProps } from '@blue-functor/remodel';
const config: ModelProps = {
reducers: {},
epics: {},
};
export default config;This file serves as the central registry for all your models. When you generate new models, the CLI automatically adds them here.
2. Creates a Providers component
import React from 'react';
import { ModelProvider } from '@blue-functor/remodel';
import models from './models';
interface ProvidersProps {
children: React.ReactNode;
}
export function Providers({ children }: ProvidersProps) {
return (
<ModelProvider config={models}>
{children}
</ModelProvider>
);
}Wrap your app root with this component to integrate ReModel.
3. Installs @blue-functor/remodel
The CLI detects your package manager (npm, yarn, pnpm, or bun) by looking for lock files and runs the appropriate install command.
4. Writes .remodel config
{
"language": "typescript",
"platform": "react",
"modelsDirectory": "./src/models"
}This config file persists your project settings so future commands use the correct defaults automatically.
Interactive Flow
When running interactively, the init command walks you through a multi-step wizard:
- Language — Select TypeScript or JavaScript
- Platform — Select React or React Native
- Models directory — Confirm or change the directory path (with filesystem autocomplete)
- Setup — The CLI creates files, installs dependencies, and writes config
- Next step — Optionally jump straight into creating your first model
If a .remodel config already exists, the CLI will overwrite it. Make sure to back up any custom settings before re-running init.