# Getting Started

### Install the Clarity SDK

```
npm i @claritydao/clarity-sdk
```

### Initialize the Clarity SDK

Before you can make use of the Clarity SDK, you must initialize it somewhere in your app.

It must be initialized somewhere on your front-end. For example, we initialize it in a `useEffect` on the home page of our example app. And then it can be called throughout the front-end without having to reinitialize.

It must also be initialized on your back-end depending on what functions you are calling. Any functions that interact with the Clarity API require a Clarity API key. As a result, these functions should only be called from the back-end to prevent leaking of the API key. Keep in mind that if you use a framework such as Next.js which uses serverless functions to act as a back-end, you will need to initialize the SDK in each serverless function that you wish to use the SDK in.

````
```typescriptreact
await ClaritySDK.initialize(
        process.env.NEXT_PUBLIC_BLOCKCHAIN_NETWORK as Networks, // "preview" or "mainnet"
        "Clarity"
      );
```
````

The following 3 parameters are required to initialize the app:

1. The network you wish to use: "mainnet" or "preview"
2. The ID of your DAO as seen in the URL of your DAO's homepage on Clarity
3. An environment variable called "CLARITY\_SDK\_API\_KEY" that holds the API key for your specific organization.

### Example App

A very basic [Next.js app utilizing the Clarity SDK](https://github.com/ClearContracts/sdk-test-app) is hosted on our GitHub.

**NOTE:** This is not an interactive app. A useful interactive example app would be difficult as everybody has individual stakes and proposals are constantly advancing through their lifecycle. However, in the repository you can see examples of all the different functions and how to properly pass in the various parameters.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sdk.clarity.vote/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
