Building Smarter White-Label Apps with Modular SDKs
If you develop a white-label app, you’ve probably faced some challenges when a client asks for a specific SDK (Software Development Kit) for analytics, deep links, or other features, and wondered how to offer multiple SDK options to different clients without increasing your app’s size or compromising its stability.
In this article, we’ll explore how to solve this problem specifically in cross-platform projects. Whether you’re building with React Native or Flutter, the goal is the same: to create a modular architecture that lets you enable or disable SDKs per client while keeping your white-label app lightweight, stable, and easy to maintain.
Challenges to Solve
When building a solution like that in a cross-platform white-label app, some challenges need to be addressed:
Managing dependencies at build time: installing, removing, and configuring them per client.
Ensuring unused native code is completely excluded to keep the app lightweight and avoid unnecessary complexity.
Handling dynamic dependency imports so features can be toggled on or off without breaking the build or increasing coupling.
Providing a unified abstraction layer so the app can interact with analytics, deep links, or other features without calling each SDK individually.
One effective way to handle build-time dependency management is by using a shell script that dynamically installs or removes SDKs based on environment variables. Before the build starts, the script can read flags such as ANALYTICS_ENABLED, DEEPLINK_ENABLED, and any client-specific configuration, and run commands like yarn add or yarn remove accordingly.
This ensures that only the required SDKs are included in the project for that particular build.
Ensuring unused native code is completely excluded
In the React Native ecosystem, this challenge is greatly simplified thanks to Expo Prebuild and Expo Config Plugins. With it, you can generate native code that includes only the SDK plugins required for a specific build.
Below is an example using the Klaviyo SDK. When expo prebuild runs, it generates the native iOS and Android projects automatically, including all the Klaviyo configuration, so you don’t need to write or maintain any native code yourself.
By wrapping the plugin definition in an environment-dependent condition (process.env.KLAVIYO_ENABLED), the SDK is only included when required for that specific build. This lets each client’s app include only the native integrations they need, without adding extra code or unnecessary dependencies.
If an SDK doesn’t provide an official Expo plugin, you can still take advantage of this workflow by creating your own custom plugin. Check this documentation for Expo Config Plugins mods.
Handling dynamic dependency imports
When you remove a dependency at build time, any direct imports of that package in your files fail since the library is no longer installed. This can break the build or cause runtime errors if not handled properly.
With that, one thing you can do is add to your shell script a capability to also create a dynamic SDK mapping file. For example:
Then, rely on this file to handle the SDK imports safely, ensuring your code never breaks when a dependency is missing.
Providing a unified abstraction layer
Having a unified abstraction layer keeps your code clean and prevents you from calling each SDK directly. For example, if you have multiple analytics SDKs, you can create an abstract analytics adapter and a global analytics class that will handle all the necessary analytics methods.
The main Analytics class then decides which SDKs to load based on the configuration, while each SDK (like Klaviyo) just implements the shared contract.
This way, the rest of your white-label app interacts with one unified interface.
How to do it on Flutter or bare React Native?
If your SDK doesn’t require custom native code, you are good. Just abstract the imports and the adapters’ logic.
However, if you do need to modify native files, things become more complex. In those cases, you can create scripts to patch Android and iOS files, build a wrapper module to encapsulate the native logic, rely on mechanisms like Android’s manifest merging, or even try to use tools like XcodeGen.
Unfortunately, there are no equivalent tools like Expo Prebuild that simplify this workflow for Flutter or bare React Native.