# Primary Domains

Users have the ability to select a domain name as their "primary". If you are a developer and want to integrate SNS to your dApp it's recommended to always use the primary domain name to replace the user's public key.

{% hint style="info" %}
Primary domains were previously called favorite domains. The naming change was made in version 3.0.0 of the SDK.
{% endhint %}

### Get a primary domain

{% tabs %}
{% tab title="web3.js v1" %}

```typescript
import { getPrimaryDomain } from "@bonfida/spl-name-service";

const { domain, reverse } = await getPrimaryDomain(connection, domainOwnerPublicKey);
```

{% endtab %}

{% tab title="web3.js v2 (@solana/kit)" %}

<pre class="language-typescript"><code class="lang-typescript">import { getPrimaryDomain } from "@solana-name-service/sns-sdk-kit";
import { Address } from "@solana/kit";

const userWallet = "36Dn3RWhB8x4c83W6ebQ2C2eH9sh5bQX2nMdkP2cWaA4" as Address

const { 
  domainAddress, // Address of domain account, not the user wallet address
<strong>  domainName: primaryDomain, 
</strong>  stale: isPrimaryDomainStale 
} = await getPrimaryDomain({ rpc, walletAddress:userWallet });
</code></pre>

{% endtab %}
{% endtabs %}

### Get multiple primary domains

To retrieve primary domains for a group of up to 100 users, we've created the `getMultiplePrimaryDomains` function in our JavaScript SDK. This function is optimized for network efficiency, making only four RPC calls, three of which are executed in parallel. The function returns a promise that resolves to an array of strings or undefined representing the primary domain, or lack thereof for each wallet passed to the function.

```typescript
import { getMultiplePrimaryDomains } from "@bonfida/spl-name-service";

const wallets = [
  new PublicKey("3ogYncmMM5CmytsGCqKHydmXmKUZ6sGWvizkzqwT7zb1"),
  new PublicKey("FMmaHPDL47V1gXsfh9WjgAT7Er3dfDvarQubTU1Jxc1r"),
  // Public Keys of all the wallet addresses you're looking up a primary domain for (up to 100)
];

const primaryDomains = await getMultiplePrimaryDomains(connection, wallets);
```

### Walkthrough

For a walkthrough tutorial on integrating Primary Domains into your dApps, check out the video below.

{% embed url="<https://youtu.be/WDneF3u5sB4>" %}


---

# 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://docs.sns.id/dev/sns-sdk/integrations.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.
