How To Run Strapi In Development Mode

Strapi admin panel

Strapi, an open-source headless CMS, provides developers with a powerful and flexible tool to create and manage content for their websites and applications. Running Strapi in development mode is essential for building and testing your applications effectively.

Prerequisites

Before starting, ensure you have:

Getting Started

1. Install Strapi

Create a new Strapi project using npm:

npx create-strapi-app@latest my-project

Or using yarn:

yarn create strapi-app my-project

Note: The older npm install strapi@beta -g method is deprecated. Always use the create-strapi-app command for new projects.

Strapi installation process

2. Choose Your Configuration

During installation, you'll be prompted to:

3. Start Development Server

Navigate to your project directory and start the development server:

cd my-project
npm run develop

Or with yarn:

cd my-project
yarn develop

4. Access the Admin Panel

Development Mode Features

Pro Tips for Development

1. Environment Configuration

# .env example
HOST=0.0.0.0
PORT=1337
APP_KEYS="your-keys-here"
API_TOKEN_SALT="your-salt-here"
ADMIN_JWT_SECRET="your-secret-here"

2. Database Management

3. Performance Optimization

4. Debugging Tools

DEBUG=strapi:* npm run develop
DEBUG=knex:query npm run develop

5. Version Control Best Practices

6. Custom Development Commands

Add these to your package.json:

{
  "scripts": {
    "develop": "strapi develop",
    "dev:clean": "rm -rf .cache && npm run develop",
    "dev:debug": "DEBUG=strapi:* npm run develop"
  }
}

Common Issues and Solutions

1. Port Conflicts

If port 1337 is already in use:

2. Database Connection

3. Memory Issues

Add to your package.json scripts:

{
  "develop": "NODE_OPTIONS=--max_old_space_size=4096 strapi develop"
}

Stopping the Development Server

Before Going to Production

  1. Test all API endpoints
  2. Review security settings
  3. Check database indexes
  4. Optimize media handling
  5. Set up proper error handling
  6. Configure proper CORS settings

Need Help?

If you encounter any issues while developing with Strapi or need assistance with setup and configuration, you can:

Check for Strapi updates and security patches regularly during development to ensure you're using the latest features and fixes.