Strapi LaunchPad

repository·main·Indexed 19 days ago

https://github.com/strapi/launchpad

The official Strapi demo application featuring a complete ecosystem with a Strapi backend and a Next.js frontend client. It includes a multilingual blog template with built-in support for English and French, responsive design using Tailwind CSS, and a set of utility functions for fetching collection types, handling Strapi media URLs, and managing content cache revalidation.

Tokens
4.9K
Snippets
27
Records
33
Agent score
65%

What's inside strapi-launchpad

  1. Overview of Next.js Multilingual Blog Template features

    main

    The template provides a foundation for building high-performance, multilingual blogs with the following capabilities:

    • Multilingual support: Built-in support for English and French.
    • Responsive Design: Fully optimized for mobile and desktop.
    • Performance & SEO: Uses Next.js for fast performance, image optimization, and SEO-friendly structures.
    • Styling: Utilizes Tailwind CSS, Framer Motion, and Aceternity UI for customizable themes.
  2. Run Strapi in production mode

    main

    Use the start command to launch your Strapi application with autoReload disabled. This mode is intended for production environments where you want a stable, non-reloading server instance.

    npm run start
    # or
    yarn start
  3. Customize the LaunchPad demo configuration

    main

    The LaunchPad demo includes specific customizations that you may want to modify:

    • Disable Anonymous Usage Tracking: The project includes a postinstall script that regenerates a UUID for anonymous usage reporting. To disable this, remove the uuid field inside the ./strapi/packages.json file.
    • API Population: The Strapi application uses custom population middlewares in every API route.
    • Admin Patch: There is a patch applied to the @strapi/admin package, which is primarily intended for hosted demo environments.
  4. Handle Strapi API errors in Next.js

    main

    When fetching content from Strapi, prevent 400 errors from crashing the application by implementing graceful error handling with fallback data. If the response is not OK, log the error and return a safe fallback (like null or an empty data array) instead of throwing.

    if (!response.ok) {
      console.error(`Failed to fetch data from Strapi (url=${url.toString()}, status=${response.status})`);
      return spreadData ? null : { data: [] };
    }
  5. Setup the Next.js Multilingual Blog Template

    main

    To run the Next.js Multilingual Blog Template locally, follow these steps:

    1. Clone the repository.
    2. Install dependencies using npm install.
    3. Create a local environment file by copying .env.example to .env.local and updating the required variables.
    4. Start the development server with npm run dev.
    5. Access the application at http://localhost:3000.
    npm install
    cp .env.example .env.local
    npm run dev
  6. Migrate to Next.js 15 and React 19

    main

    To upgrade the Next.js application to Next.js 15.5.0 and React 19.1.1, follow these steps:

    1. Run the Upgrade Codemod: Use npx instead of yarn dlx to avoid compatibility issues during the upgrade process.
    2. Update Dependencies: Ensure framer-motion is updated to at least v12.23.12 for React 19 compatibility.
    3. Install Packages: Use the --legacy-peer-deps flag during installation to resolve dependency resolution conflicts common in this upgrade.

    Migration Commands:

    # Upgrade the project using the Next.js codemod
    npx @next/codemod@canary upgrade ./
    
    # Install dependencies with legacy peer deps support
    npm install --legacy-peer-deps
    npx @next/codemod@canary upgrade ./
    npm install --legacy-peer-deps
  7. Resolve Hydration Mismatches in Next.js

    main

    To prevent hydration mismatches in Next.js components, avoid using non-deterministic values like Math.random() or certain useId() implementations that might differ between the server and client. Instead, use deterministic ID generation based on stable props like an index.

    Example Fix:

    // Instead of Math.random()
    const id = `circle-line-${index}`;
  8. Run Strapi in development mode

    main

    Use the develop command to start your Strapi application with autoReload enabled. This is the recommended way to work during local development as it automatically restarts the server when you make changes to your code.

    npm run develop
    # or
    yarn develop
  9. Install and run the LaunchPad demo

    main

    Follow these steps to set up the LaunchPad demo locally, which includes both a Strapi backend and a Next.js frontend.

    Prerequisites

    • Node.js v18 or higher
    • Yarn (enable via corepack enable or install via npm install -g yarn)

    Setup Steps

    1. Clone and Install root dependencies:
      git clone https://github.com/strapi/launchpad.git
      cd launchpad
      yarn install
    2. Configure projects: Run the setup script to install dependencies for both the Strapi and Next.js packages and copy the necessary environment files:
      yarn setup
    3. Seed the database: Populate the Strapi instance with the demo content:
      yarn seed
    4. Start development servers: Launch both servers concurrently. This command starts the Strapi server first, waits for it to be ready, and then starts the Next.js frontend:
      yarn dev

    Accessing the applications

    git clone https://github.com/strapi/launchpad.git
    cd launchpad
    yarn install
    yarn setup
    yarn seed
    yarn dev