Widget Builder is a command-line tool that lets you build, edit, and preview custom storefront widgets in real time, outside the context of your BigCommerce store.
This article is a guide to help you learn how to use Widget Builder.
Because the OAuth scope of these API credentials permits you to modify store content, we strongly recommend that you develop widgets using a sandbox store.
For more information on authentication, see Authentication.
To install Widget Builder and its dependencies, follow these instructions:
npm.Refer to the Widget Builder README.md for the latest supported Node.js and npm versions.
Clone the widget-builder GitHub repository.
Navigate to the widget-builder directory, and install Widget Builder using the following command:
To retrieve usage information and view supported options and commands, run the following command:
Sample output:
Once you have installed Widget Builder, the next step is to configure your development environment with your store’s authentication credentials so that you can work with your store’s data during the development process. You’ll need the store’s Client ID, Access Token, and API Path. To configure the environment, follow these instructions:
Sample input:
widget-builder init.Sample session:
If you need to reset the configuration, you can run the widget-builder init command in the same directory to overwrite the existing assignments. Running widget-builder init in a sibling directory will create a separate development environment.
Initializing Widget Builder at multiple levels of a single file hierarchy can have unpredictable results and is not recommended.
To use Widget Builder as a development tool, you must run widget-builder commands from the same directory where you ran widget-builder init.
createJump-start widget development with Widget Builder’s create command, which creates a child directory, populates it with blank template files, and starts a development server. To use the generator, run the following command:
Sample output:
Your default browser will open automatically and display a text widget on port 8080.
startWidget Builder’s start command will start the development server for an existing widget that is located in a child directory of the environment root. Navigate to that environment root, then run the following command:
Sample output:
Your default browser will open automatically on port 8080.
To publish a widget to your BigCommerce store, navigate to its environment root, then run the following command:
Publishing a widget from the same path will update or overwrite your existing widget. If you have a widget with the same name currently deployed in your store, the updated widget will immediately replace the previous version on your live storefront.
To add published widgets to your store, open your store’s control panel and navigate to Storefront > My Themes. Click the Customize button on your active theme, and locate your published widget in the Custom section of the left-side menu.
If you’re interested in making your widgets available for download or sale on other stores, check out the BigCommerce App Marketplace and learn about becoming a partner developer.