strapi2front CLI provides commands to initialize your project and sync types, services, and actions from your Strapi schema.
Installation
Commands
init
Initialize strapi2front in your project. Creates configuration files, sets up environment variables, and installs dependencies.
If you run
strapi2front without any command, it defaults to running init.Options
Skip interactive prompts and use default values for all options.
Strapi URL to connect to (e.g.,
http://localhost:1337). If not provided, you’ll be prompted during setup.Strapi sync token with
STRAPI_SYNC_TOKEN permissions. Required for fetching schema. If not provided, you’ll be prompted.Framework to use for action generation. Currently supports
astro. Auto-detected if not specified.What it does
Theinit command performs the following steps:
- Detects project configuration: Framework, TypeScript usage, and package manager
- Runs interactive prompts: Collects configuration options through guided questions
- Creates configuration file: Generates
strapi.config.ts(or.jsfor JSDoc projects) - Updates environment files:
- Appends variables to
.env(creates if needed) - Creates
.env.examplewith token documentation
- Appends variables to
- Creates output directory: Sets up the directory structure for generated files
- Installs dependencies: Optionally installs
strapi2front(dev) and@strapi/client
Environment Variables
The init command creates the following environment variables:Your Strapi backend URL (e.g.,
http://localhost:1337 or https://api.example.com)Development only - Token for syncing schema from Strapi.Permissions required:
content-type-builder.getContentTypescontent-type-builder.getComponentsi18n.listLocales
Production - Token for your frontend app to fetch content. Configure with only the permissions your app needs.
Public URL for browser-side uploads (only if upload feature is enabled)
Upload token with
Upload > upload permission only (no delete/update)Examples
sync
Sync types, schemas, services, actions, and upload helpers from your Strapi schema. This is the main command you’ll run after making changes to your Strapi content types.
Options
Force regeneration of all files, even if they haven’t changed.
Only generate TypeScript type definitions. Skips services, actions, schemas, and upload helpers.
Only generate service files for API calls. Skips types, actions, schemas, and upload helpers.
Only generate framework actions (Astro actions). Skips types, services, schemas, and upload helpers.
Only available when
outputFormat: "typescript" in configOnly generate Zod validation schemas. Skips types, services, actions, and upload helpers.
Only generate upload helpers (action + public client). Skips types, services, actions, and schemas.
What it does
Thesync command:
- Loads configuration from
strapi.config.ts - Detects Strapi version (v4 or v5) and warns if config mismatch
- Fetches schema from Strapi API (content types, components, locales)
- Checks for Blocks fields and prompts to install
@strapi/blocks-react-rendererif needed - Generates files based on your feature configuration:
- Types: TypeScript interfaces for all content types and components
- Services: API client methods for CRUD operations
- Actions: Framework-specific server actions (Astro)
- Schemas: Zod validation schemas for forms
- Upload: File upload helpers for client and server
- Displays summary of generated files
Generated File Structure
With all features enabled, sync generates:Examples
Global Options
These options are available for all commands:Display help information for a command.
Display the installed strapi2front version.
Exit Codes
Command completed successfully
Command failed with error (check error message)
Package Manager Detection
The CLI automatically detects your package manager based on lockfiles:bun.lockb→ Bunpnpm-lock.yaml→ pnpmyarn.lock→ Yarn- Default → npm