> ## Documentation Index
> Fetch the complete documentation index at: https://dev.smile.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Initializing Smile UI

> `SmileUI.initialize(options)`

This method initializes Smile UI with information about the loyalty program to display and the currently logged in customer. This method must be called before you can interact with any other methods.

> [!NOTE]
>
> If you're loading the `Smile UI` script asynchronously, you should wrap your initialization code within a [loaded event](https://dev.smile.io/ui/events/ui-loaded.md) to ensure it doesn't encounter an error due to the script not yet being present on the page.

## Parameters

**options** `object` *required*

**properties**

**publishableKey** `string` *required*

Your Smile.io publishable key. This is used for identifying your store and can be made public. Refer to the [help docs](https://help.smile.io/en/articles/11878403-find-publishable-key) for where to find it.

**customerToken** `string`

A [customer token](https://dev.smile.io/ui/customer-tokens.md) identifying the currently logged-in customer. This should be `null` or omitted entirely if no customer is currently logged-in.

**includeSdk** `boolean` (default: false)

Whether to load and initialize Smile's [JavaScript SDK](https://dev.smile.io/js/introduction.md) (Smile.js) alongside Smile UI. This is useful when you also want the JavaScript SDK's methods and objects available on the page.

## Returns

This method does not return a value. To detect when initialization is complete, use [`SmileUI.ready()`](https://dev.smile.io/ui/smile/ready).

```javascript JavaScript lines theme={null}
// If the script is loaded synchronously
SmileUI.initialize({
  publishableKey: "pub_0987654321",
  customerToken:
    "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhcGkuc21pbGUuaW8iLCJzdWIiOiJTaG9waWZ5Q3VzdG9tZXI6MTA3MzM0NTgiLCJleHAiOjE1ODU1OTE1MzZ9.3SOqHMbmqvfuzHLrABbFNzwlgkFJnj8xtubttfmM4-o",
});

// If the script is loaded asynchronously
document.addEventListener("smile-ui-loaded", () => {
  SmileUI.initialize({
    publishableKey: "pub_0987654321",
    customerToken:
      "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhcGkuc21pbGUuaW8iLCJzdWIiOiJTaG9waWZ5Q3VzdG9tZXI6MTA3MzM0NTgiLCJleHAiOjE1ODU1OTE1MzZ9.3SOqHMbmqvfuzHLrABbFNzwlgkFJnj8xtubttfmM4-o",
  });
});
```
