> For the complete documentation index, see [llms.txt](https://docs.vechainkit.vechain.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vechainkit.vechain.org/vechain-kit-v1.x/vechain-kit/troubleshooting/integration-issues/privy-popup-blocking.md).

# Privy Popup Blocking

Browser popup blocking can affect users using social login (Privy) when operations delay the signing popup.

### Problem

When using Privy for social login (cross-app connection), browsers may block the confirmation popup if there's a delay between user\
action and popup trigger.

#### What Causes This

* Fetching data after button click
* API calls before signing
* Any async operations between click and popup

### Solution

#### Pre-fetch Data Before Transaction

Ensure all required data is loaded before the user clicks the button:

```javascript
// ✅ Good: Pre-fetch data
const { data } = useQuery(['someData'], fetchSomeData);
const sendTx = () => sendTransaction(data);

// ❌ Bad: Fetching data during the transaction
const sendTx = async () => {
  const data = await fetchSomeData();  // This delay causes popup blocking
  return sendTransaction(data);
};
```

#### Best Practices

1. **Load Data Early**

<pre class="language-javascript"><code class="lang-javascript">// Load data when component mounts or when form changes
const { data: gasPrice } = useQuery(['gasPrice'], fetchGasPrice, {
    staleTime: 30000 // Cache for 30 seconds
});
// Transaction handler is instant
const handleTransaction = () => {
    sendTransaction({
        gasPrice,
        // ... other pre-loaded data
<strong>    });
</strong>};
</code></pre>

2. **Show Loading States**

```javascript
const MyComponent = () => {
    const { data, isLoading } = useQuery(['requiredData'], fetchData);

    return (
      <button 
        onClick={() => sendTransaction(data)}
        disabled={isLoading}
      >
        {isLoading ? 'Preparing...' : 'Send Transaction'}
      </button>
    );
  };

```

3. **Avoid Async in Click Handlers**

```javascript
// ❌ Avoid
onClick={async () => {
  const result = await someAsyncOperation();
  sendTransaction(result);
}}

// ✅ Better
onClick={() => {
  sendTransaction(preLoadedData);
}}
```

#### **Testing**

To test if your implementation avoids popup blocking:

1. Use social login (Privy)
2. Click transaction buttons
3. Popup should appear immediately
4. No browser blocking warnings

#### **Common Scenarios**

* **Form submissions**: Validate and prepare data before `submit` button is enabled
* **Token approvals**: Pre-fetch allowance amounts
* **Multi-step transactions**: Load all data for subsequent steps upfront


---

# 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 dynamically by asking a question.

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

```
GET https://docs.vechainkit.vechain.org/vechain-kit-v1.x/vechain-kit/troubleshooting/integration-issues/privy-popup-blocking.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
