> ## 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.

# Initialize the SDK

> `Smile.initialize(options)`

This async method initializes the SDK with information about the loyalty program and the currently logged-in customer. This method must be called before you can interact with other methods provided by the SDK.

<Warning>
  If you're loading the SDK script asynchronously, you should wrap your initialization code with a [loaded event](/js/concepts/loaded-event) to ensure it doesn't encounter an error due to the script not yet being present on the page.
</Warning>

## Parameters

<ParamField path="options" type="object" required>
  <Expandable title="properties">
    <ParamField path="publishableKey" type="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-a-publishable-key) for where to find it.
    </ParamField>

    <ParamField path="customerToken" type="string">
      A [customer token](/js/concepts/customer-tokens) identifying the currently logged-in customer. This should be `null` or omitted entirely if no customer is currently logged-in.
    </ParamField>

    <ParamField path="preload" type="array">
      An array with one or multiple of the available [resource keys](/js/concepts/preloading#resources-that-can-be-preloaded).
    </ParamField>
  </Expandable>
</ParamField>

## Returns

This method returns a `Promise` that:

* On success, resolves to void. The SDK will be initialized and ready for use.
* On failure, rejects with an [error object](/js/concepts/error-object).

If the method is improperly invoked (e.g. missing `publishableKey`), the `Promise` will be rejected.

<Panel>
  ```javascript JavaScript lines theme={null}
  // If the script is loaded synchronously
  Smile.initialize({
    publishableKey: 'pub_0987654321',
    customerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhcGkuc21pbGUuaW8iLCJzdWIiOiJTaG9waWZ5Q3VzdG9tZXI6MTA3MzM0NTgiLCJleHAiOjE1ODU1OTE1MzZ9.3SOqHMbmqvfuzHLrABbFNzwlgkFJnj8xtubttfmM4-o',
    preload: ['pointsSettings']
  });

  // If the script is loaded asynchronously
  document.addEventListener('smile-js-loaded', () => {
    Smile.initialize({
      publishableKey: 'pub_0987654321',
      customerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJhcGkuc21pbGUuaW8iLCJzdWIiOiJTaG9waWZ5Q3VzdG9tZXI6MTA3MzM0NTgiLCJleHAiOjE1ODU1OTE1MzZ9.3SOqHMbmqvfuzHLrABbFNzwlgkFJnj8xtubttfmM4-o',
      preload: ['pointsSettings']
    });
  });
  ```
</Panel>
