Installation
This guide covers everything you need to install and configure Strapi2Front in your project.System Requirements
Node.js
Version 18.0.0 or higher required
Strapi
Strapi v4 or v5 instance (local or remote)
Package Manager
npm, pnpm, yarn, or bun
TypeScript (Optional)
Works with both TypeScript and JavaScript projects
Installation Methods
Interactive Setup (Recommended)
The easiest way to get started is using the interactiveinit command:
- Detect your project configuration (framework, TypeScript, package manager)
- Prompt for Strapi connection details (URL, token, version)
- Create configuration file (
strapi.config.tsorstrapi.config.js) - Set up environment variables (
.envand.env.example) - Install dependencies (optional)
The
init command is safe to re-run. It won’t overwrite existing environment variables.Manual Installation
If you prefer manual setup:1
Install the package
Add Strapi2Front as a dev dependency:
strapi2frontis a dev dependency (used for code generation)@strapi/clientis a runtime dependency (used by generated code)
2
Create configuration file
Create
strapi.config.ts (or .js for JavaScript projects):- TypeScript
- JavaScript (ESM)
- JavaScript (CommonJS)
strapi.config.ts
3
Set up environment variables
Create or update your Create
.env file:.env
.env.example for your repository:.env.example
Strapi API Token Setup
Strapi2Front requires an API token with specific permissions to read your content type schema.1
Create API Token in Strapi
Navigate to your Strapi admin panel:Settings > API Tokens > Create new API Token
2
Configure Token Settings
- Strapi v5
- Strapi v4
- Token name:
strapi2front-sync - Token type:
Custom - Token duration:
Unlimited(for development)
- ✅ Content-type-builder
- Components:
getComponents,getComponent - Content-types:
getContentTypes,getContentType
- Components:
- ✅ I18n (if using localization)
- Locales:
listLocales
- Locales:
3
Save and Copy Token
Click Save and copy the generated token immediately.Add it to your
.env file:Why two tokens?
STRAPI_SYNC_TOKEN: Used by the CLI to read your schema (development only, should NOT be deployed)STRAPI_TOKEN: Used by your app to fetch content (production, with limited read-only permissions)
STRAPI_SYNC_TOKEN if available, otherwise falls back to STRAPI_TOKEN.File Upload Token (Optional)
If you enable theupload feature, you’ll need an additional token for file uploads:
1
Create Upload Token
In Strapi admin: Settings > API Tokens > Create new API Token
- Token name:
upload-token - Token type:
Custom - Duration: As needed
- Permissions:
- ✅ Upload
upload(only)
- ❌ No delete or update permissions (security best practice)
- ✅ Upload
2
Add to Environment
Add both the URL and token:
.env
The
PUBLIC_ prefix makes these variables available in client-side code (framework-specific naming may vary).Verify Installation
Run the sync command to verify everything is set up correctly:Framework-Specific Setup
Astro
1
Install Astro dependencies
2
Enable server output
If using Astro Actions, ensure your
astro.config.mjs has:astro.config.mjs
3
Configure environment variables
Astro uses
PUBLIC_ prefix for client-side variables:.env
Next.js
1
Configure environment variables
Next.js uses
NEXT_PUBLIC_ prefix for client-side variables:.env.local
2
Update strapi.config.ts
Point output to your src/lib directory:
strapi.config.ts
Nuxt
1
Configure environment variables
Nuxt uses
NUXT_PUBLIC_ prefix:.env
SvelteKit
1
Configure environment variables
SvelteKit uses
PUBLIC_ prefix:.env
NPM Scripts (Optional)
Add convenient scripts to yourpackage.json:
package.json
CI/CD Integration
To sync types in your CI/CD pipeline:Next Steps
Quick Start
Get started with your first query
Configuration
Explore all configuration options
CLI Reference
Learn all available commands
Guides
Learn about types, services, and schemas