> For the complete documentation index, see [llms.txt](https://developer.paddle.com/llms.txt).

# Paddle.Update()

Use to update values passed to Paddle.js during initialization.

---

Use `Paddle.Update()` to update values sent to Paddle.js during initialization. This is typically used when working with single page applications to pass an updated customer to `pwCustomer` when a customer is identified.

You must call `Paddle.Initialize()` before calling `Paddle.Update()`. Use the `Paddle.Initialized` flag to determine whether you need to call `Paddle.Initialize()` or `Paddle.Update()`.

## Parameters

```yaml
title: Paddle.Update() properties
type: object
properties:
  pwCustomer:
    type:
      - object
      - "null"
    description: >-
      Identifier for a logged-in customer for Paddle Retain. Pass an empty object if you don't have a logged-in
      customer. Paddle Retain is only loaded for live accounts.
    properties:
      id:
        type: string
        description: >-
          Paddle ID of a customer entity, prefixed `ctm_`. Only customer IDs are accepted. Don't pass subscription IDs,
          other Paddle IDs, or your own internal identifiers for a customer.
  eventCallback:
    # The underlying JSON Schema type is object|null (functions are objects in JS)
    # but the docs need to display the TypeScript callable signature instead.
    type:
      - object
      - "null"
    x-display-type: "(event: EventData) => void | null"
    description: Function to call for Paddle.js events.
```

## Examples

{% accordion %}

{% accordion-item title="Update customer for Retain" %}

This example passes a new `pwCustomer` to Paddle.js using `Paddle.Update()`.

{% tabs sync="paddlejs-preference" %}
{% tab-item title="Using a script tag" %}

```js
Paddle.Update({
  pwCustomer: {
    id: "ctm_01gt25aq4b2zcfw12szwtjrbdt",
  },
});
```

{% /tab-item %}
{% tab-item title="Using a JavaScript package manager" %}

```ts
import { initializePaddle } from "@paddle/paddle-js";

const paddle = await initializePaddle({
  pwCustomer: {
    id: "ctm_01gt25aq4b2zcfw12szwtjrbdt",
  },
});
```

{% /tab-item %}
{% /tabs %}

{% /accordion-item %}

{% accordion-item title="Check if Paddle is initialized before updating" %}

This example checks if Paddle is initialized using the `Paddle.Initialized` flag, then calls `Paddle.Update()` to set `pwCustomer` if not initialized.

{% tabs sync="paddlejs-preference" %}
{% tab-item title="Using a script tag" %}

```js
if (Paddle.Initialized) {
  Paddle.Update({
    pwCustomer: {
      id: "ctm_01gt25aq4b2zcfw12szwtjrbdt",
    },
  });
} else {
  Paddle.Initialize({
    token: "live_7d279f61a3499fed520f7cd8c08",
    checkout: {
      displayMode: "overlay",
      theme: "dark",
      locale: "en",
    },
    pwCustomer: {},
  });
}
```

{% /tab-item %}
{% tab-item title="Using a JavaScript package manager" %}

```ts
import { initializePaddle } from "@paddle/paddle-js";

if (window.Paddle?.Initialized) {
  await initializePaddle({
    pwCustomer: {
      id: "ctm_01gt25aq4b2zcfw12szwtjrbdt",
    },
  });
} else {
  await initializePaddle({
    token: "live_7d279f61a3499fed520f7cd8c08",
    checkout: {
      settings: {
        displayMode: "overlay",
        theme: "dark",
        locale: "en",
      },
    },
    pwCustomer: {},
  });
}
```

{% /tab-item %}
{% /tabs %}

{% /accordion-item %}

{% /accordion %}