# Initialize the widget

Source: https://developer.avalara.com/products/self-serve-tariff-code/integration-guides/classyvue-integration-guide/dse0254864354780/

Guide: ClassyVue integration guide

# Initialize the widget

For single-page applications where the widget container mounts after the initial page load, ClassyVue must be initialized manually. Learn when and how to use `ccce.init()` to initialize the widget.

By default, ClassyVue initializes automatically when the script loads, using the `runOnload` attribute. This works when the host

container is present in the DOM at page load time. For single-page applications (SPAs) built with frameworks like React, Vue, or Angular, the container

doesn’t exist when the script first runs. The script runs before the route or component that contains the

mounts.

In these cases, omit `runOnload` from the script tag and call `ccce.init()` manually once the container element is mounted:

```
functioninit() {
  const el = document.querySelector('script[data-element-id]');
  ccce.init(el);
}
```

Tip

Reinitialize `ccce.init()` whenever the user navigates away from and back to the route that hosts the classifier. The iframe is destroyed when the container

unmounts, so a fresh initialization is required each time the component remounts.