BigCommerce App Extensions allow developers to extend the control panel's capabilities by registering custom menu items that appear on select native control panel pages.
When a control panel user clicks an App Extension-generated menu item, the app can either render content in a side panel without navigating the user away from the native page, or it can redirect the user to the app's home iframe in the Apps sub-menu, and render App Extension-specific content there.
Your Gadget frontend routes can be used to power App Extensions.
Add an appExtensionIdstring field to your bigcommerce/store model.
Each app can install up to 2 App Extensions per store. If you are installing 2 App Extensions, you can use 2 fields or store both IDs in a
single string or json field.
Step 3: Register the App Extension with the store on install
Paste the following code into api/models/bigcommerce/store/install.js to create a new App Extension and save the App Extension ID to your bigcommerce/store model when your app is installed on a store.
Make sure to update the input variable of the GraphQL mutation to match the type of App Extension you want to create:
For production apps, you may also want to run the same code in api/models/bigcommerce/store/reinstall.js.
Step 4: Set up frontend routing
Add a new file to your web/routes folder and add a route to your router in web/components/App.jsx.
For example, if you used the above example for your App Extension and set the url to /products/${id}/interactions, you would need to add the following to your route definition in web/components/App.jsx
Then create a new file at web/routes/appExtension.jsx and build your App Extension UI:
web/routes/appExtension.jsx
React
1import{Panel,Text}from"@bigcommerce/big-design";
2import{ useParams }from"react-router";
3
4exportdefaultfunction(){
5// useParams hook to get route param from BigCommerce
6const{ productId }=useParams();
7
8return(
9<>
10<Paneldescription="Successfully created an App Extension!">
11<Text>This extension is for product {productId}!</Text>
12</Panel>
13</>
14);
15}
1import{Panel,Text}from"@bigcommerce/big-design";
2import{ useParams }from"react-router";
3
4exportdefaultfunction(){
5// useParams hook to get route param from BigCommerce
6const{ productId }=useParams();
7
8return(
9<>
10<Paneldescription="Successfully created an App Extension!">
11<Text>This extension is for product {productId}!</Text>
12</Panel>
13</>
14);
15}
The useParams hook is used to grab the productId included in the route path.
Step 5: Test your App Extension
Once you finish adding your routes and the custom backend code, you need to:
Uninstall your app from the sandbox.
Delete the existing bigcommerce/store record from the Gadget database. This can be done on the bigcommerce/store model's data page: api/models/bigcommerce/store/data.
Install your app back on the sandbox.
This will run your GraphQL mutation on install and register the App Extension.