> For the complete documentation index, see [llms.txt](https://docs.nosto.com/ugc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nosto.com/ugc/guides/widgets-nextgen/typescript-api-guides/how-to-use-the-sdk.md).

# How to use the SDK

{% hint style="warning" %}
You are reading the **NextGen Documentation**

**NextGen widgets** are a new and improved way to display UGC content onsite.&#x20;

From September 23rd 2025, all new widgets created will be NextGen.

Please check your widget version on the **Widget List page** to see if it is a **Classic** or **NextGen** widget.

**Note: This feature is exclusive to NextGen widgets.**
{% endhint %}

The SDK can be utilised to power your widget with advanced functionality.

The SDK gives developers access to:

1. Their widget placement, along with all the parameters associated with it
2. The tiles service, allowing the manipulation of the tiles visible, and hidden.
3. The events service, allowing particular events to be hooked into, or emitted.

While the SDK is documented in the Understanding the SDK page, here is an example of how it has been utilised to build search functionality in the blank canvas widget template.

```
import { ISdk, loadWidget } from "@stackla/widget-utils"
import { config } from "./config"

declare const sdk: ISdk

loadWidget(sdk, {
  config: {
    ...config
  }
})

sdk.querySelector("#search-input")?.addEventListener("input", async e => {
  const eventTarget = e.target
  if (eventTarget instanceof HTMLInputElement) {
    const searchValue = eventTarget.value
    await sdk.tiles.searchTiles(searchValue)
  }
})
```

As soon as the widget is loaded, I perform a `querySelection` on an item in the placement using the SDK.

I attach an event, so that every time the input is modified, it performs a live search of the selection of tiles.

Note: Here I am accessing the Tiles Service via `sdk.tiles` and there is a plethora of methods that can be utilised to manipulate the tile view.

Now, every time a user searches, the tiles update to their search results.

Under the hood, this is how the tile search method is implemented

```
  public async searchTiles(query: string, clearExistingTiles: boolean = true) {
    this.widgetRequest.search = query

    if (clearExistingTiles) {
      const tiles = this.getPlacement().querySelector(".ugc-tiles")
      if (!tiles) {
        return
      }

      this.tiles = {}
      tiles.innerHTML = ""
    }

    return this.fetchTiles()
  }
```

This same functionality can take place in your code, without the use of the `searchTiles` method here, by utilising the suite of methods in the Tile Service.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nosto.com/ugc/guides/widgets-nextgen/typescript-api-guides/how-to-use-the-sdk.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
