Skip to navigation

App Development Best Practices

These recommendations help you build a reliable, secure app. They go beyond the standards the Marketplace team reviews every submission against. For those, see the approval requirements, and check your app against them before you submit it.

OAuth flow

Follow security best practices and requirements

RFC 6749 discusses OAuth security considerations, recommendations, and requirements. Here’s a summary of important items applicable to apps:

  • Request access tokens with minimal scopes necessary.
  • Serve all redirect URIs over TLS.
  • Keep access tokens confidential in transit and storage.
  • Do not transmit access tokens, refresh tokens, or client credentials in the clear.
  • Do not transmit authorization codes in the clear.
  • Educate end-users about the risks phishing attacks pose.
  • Provide mechanisms that make it easy for end-users to confirm the authenticity of your app.
  • Implement CSRF protection on redirect URI.

For details, see Security Considerations in RC6749. For a list of the top web application security risks and best practices to avoid them, see OWASP Top Ten.

API requests

For recommendations on API request-related best practices, including rate limits, threading, parallel requests, and the finer points of request headers, see our article on Best Practices.

Webhook events

Use webhooks to keep app data up-to-date

Rather than polling endpoints, get notified when updates occur by subscribing to webhooks.

User interface

Manage user session timeouts

The BigCommerce SDK keeps your app synchronized with the control panel, which matters because your app runs in an iframe and can’t otherwise see control panel events. For example, the SDK can tell your app when the user logs out of the control panel, even from a different tab. Since the SDK runs as frontend code, it must run in the browser.

Load the SDK script from https://cdn.bigcommerce.com/jssdk/bc-sdk.js. The SDK calls window.bcAsyncInit once it loads, and you initialize the SDK inside that function:

window.bcAsyncInit = function() {
Bigcommerce.init({
onLogout: callback
});
}

To enhance security, pass an onLogout callback, which triggers when a user logs out of the control panel, even from a separate tab.

In Next.js, load the script with next/script in a client component, and define window.bcAsyncInit in an effect. Also call window.bcAsyncInit?.() from onLoad. If the script finishes loading before the effect runs, the SDK has already missed bcAsyncInit, so this call initializes it directly:

"use client";
import { useEffect } from "react";
import Script from "next/script";
export function BigCommerceControlPanelSync() {
useEffect(() => {
window.bcAsyncInit = () => {
window.Bigcommerce?.init({
onLogout: () => {
// Clear your app's own session here
},
});
};
return () => {
delete window.bcAsyncInit;
};
}, []);
return (
<Script
strategy="afterInteractive"
src="https://cdn.bigcommerce.com/jssdk/bc-sdk.js"
onLoad={() => window.bcAsyncInit?.()}
/>
);
}

In TypeScript, declare bcAsyncInit and Bigcommerce on Window first. For the full implementation, including that declaration and a Server Action that clears the app’s session cookie on logout, see the starter app’s control panel sync component.

Streamline new user onboarding

  • If your app has a new user form, auto-fill the fields with data from the Store Information API, and don’t ask for information you can already get.
  • If your app doesn’t have an approval process for new users, consider automatically generating accounts for new stores that install your app.
  • If your app requires the user to sign in at launch, use the information BigCommerce sends to your callback URL to authenticate the user without asking for a username and password each time.

Offer multi-user access

Multi-user support is a requirement for approval. It means your app lets other authorized users in the store open it, and it saves each store’s access token against the store, not against a user’s email address. It doesn’t require you to build user permissions into your app. If you want to go further, consider these enhancements:

  • Let store owners remove users. Write a remove_user callback and add its URL to your app’s Developer Portal profile. This is optional.
  • Offer per-user permissions. Let the store owner grant specific permissions to different non-admin users. For example, person1@example.com could be permitted to edit product inventory but not view orders. If you add this to your app, it’s a great feature to advertise.

To tell store owners from other users, compare the owner and user claims in the load payload. For details, see Single-click app callbacks. For setup, see Supporting multiple users.

Deployment

Consider hosting on Google Cloud Platform’s us-central1 region

BigCommerce hosts Google Cloud Platform in the us-central1 region; maximize performance by hosting in the same region.

Next steps

Resources

Sample apps

Tools

Blog posts