When we’re about to start building a new app, you’ll likely come across the need to install third-party libraries to achieve a specific goal or feature.

Smart Builder SDK comes with a built-in utility component called Script and receives the following object parameters:

So, we can translate the above properties into the following interfaces:

// This first interface is the expected in the Script util function.
interface ScriptConfig {
  mode: 'publish' | 'view';
  inlineScript?: string;
  externalScript?: ExternalScript;
  dependencies: unknown[];
}

interface ExternalScript = {
  scriptId: string;
  src: string;
  onloadMethod: string;
  condition: boolean;
}

Please review this sample code to see an example of this function: Loading an External Script Using the Built-in component.