Make your first section

With Crane framework, you can build and deploy custom sections within the Lightspeed E-Commerce ecosystem.

Prerequisites

Before using Crane CLI, you need:

  1. Node.js 22.x - Recommended for best compatibility

  2. Lightspeed Application - Contact your Partner Manager for:

    • Application credentials (client ID and secret)

    • Test site access for verification

    • Required permissions

Installation

Install Crane and its dependencies in your project:

npm install vite vue @lightspeed/crane@latest @lightspeed/eslint-config-crane@latest

Commands

Initialize a New Application

Create a new Crane application:

npx @lightspeed/crane@latest init --app app-name
keyboard

If you omit the app-name, you'll be prompted to enter it interactively.

This creates:

  • Application folder with default resources

  • Configuration files

  • Assets and TypeScript files

  • One example section in sections/example-section

Example with specified app name:

Example with no specified app name:

Create a New Section

Add a custom section to your application:

folder

Run this command from your application folder (created with init --app).

keyboard

If you omit the section-name, you'll be prompted to enter it interactively.

Creates section files in sections/<name> directory.

Example:

By providing the --blank flag, you can create a section with the minimum required files for the section to work.

Build the Application

Build your application for deployment:

Creates dist and node_modules directories with compiled output.

Preview Locally

Start a local development server:

Features:

  • Opens preview URL in your terminal

  • Hot reload - build once, refresh browser to see changes

  • No need to restart after subsequent builds

Deploy to Lightspeed

Deploy your application to production:

sliders

Get Help

Display available commands and options:

Configuration

crane.config.json

Configure your application credentials in crane.config.json:

triangle-exclamation

Complete Workflow Example

Here's a typical workflow for creating and deploying a Crane application:

1. Create Application

2. Add Custom Templates

3. Add Custom Sections (Optional)

4. Configure Credentials

Edit crane.config.json:

5. Develop and Preview

book-open

Want to know more about Crane CLI commands?

Jump into Deep dive into Crane CLI

Open the preview URL in your browser and test your sections.

6. Deploy

Troubleshooting

Build Failures

If the build command fails:

HTTP 401 Error During Deployment

Cause: Invalid credentials

Solution: Verify crane.config.json has correct app_client_id and app_secret_key

HTTP 403 Error During Deployment

Cause: Insufficient permissions

Solution: Contact your Partner Manager to grant the necessary permissions

Preview Not Working

Cause: Build artifacts missing or outdated

Solution:

Project Structure

A typical Crane application structure:

Learn more

  • Sections — Master your knowledge on section components and configurations

  • Section Collections — Create redistributable section packages

Last updated

Was this helpful?