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

# Login the customer

> `Smile.customer.login(customerToken, options?)`

This async method logs in a customer using the provided token while also [preloading resources](/js/concepts/preloading) into the cache.

## Parameters

<ParamField path="customerToken" type="string" required>
  A [customer token](/js/concepts/customer-tokens) identifying the individual who is being 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>

## Returns

This method returns a `Promise` that:

* On success, resolves to void.
* On failure, rejects with an [error object](/js/concepts/error-object).

<Tip>
  To access customer data after login has completed, use [`Smile.customer.current()`](/js/resources/customer/current) . To access any of the resources that were preloaded as part of the login call, use their respective `preloaded()` methods.
</Tip>

<Panel>
  ```javascript JavaScript lines theme={null}
  // Basic login
  Smile.customer.login({
    customerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
  }).then(() => {
    // Customer logged in successfully
  });

  // Login with preloading
  Smile.customer.login({
    customerToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
    preload: ['rewardFulfillments']
  }).then(() => {
    // Customer logged in and preloaded resources successfully
  });

  ```
</Panel>
