# Save a talent build

Collect a complete build in a dialog and save it in your application.

Source: https://warcraftforever.com/developers/recipes/save-a-build/

## Mount after opening your build dialog

Load the talent script once. Then create a mount each time your dialog opens:

```js
const talents = WarcraftForever.Talents.mount('#talent-editor', {
  class: selectedClass,
  maxLevel: 30,
  build: savedBuild,
});

const unsubscribe = talents.on('submit', async (state) => {
  await saveBuild({
    class: state.class,
    code: talents.exportBuild('blizzard'),
    revision: state.revision,
  });
  closeBuildDialog();
});

await talents.ready;
```

`selectedClass`, `savedBuild`, `saveBuild`, and `closeBuildDialog` belong to your application. Omit `build` for a new allocation. Use an empty mount element and show loading or errors while `ready` settles.

This example sets a level cap of 30; choose the cap your application needs. The SDK shows Save when all available points are legally allocated (21 at level 30). The `submit` event carries the completed state; saving to your backend remains your responsibility.

## Close or change class

```js
unsubscribe();
talents.destroy();
```

Call these when your dialog closes. Changing the class through `update({ class: nextClass })` resets the build unless you also supply a build for that class.

## Show the saved result

Use [linked icons or a read-only tree](https://warcraftforever.com/developers/talents/saved-builds/) to display the saved build. Preserve the revision and run [backend validation](https://warcraftforever.com/developers/reference/security/#validate-on-your-server) before accepting a submission.
