# Puppeteer

## 📌 **Requirements**

To use **Puppeteer** on Discloud, a minimum of **512 MB RAM** is recommended for basic tasks. However, depending on the complexity of your application, **more RAM** may be required.

{% hint style="warning" %}
**If Puppeteer does not function correctly (e.g., no QR code in logs, crashes), increase the allocated RAM!**
{% endhint %}

***

## 📦 **Adding Puppeteer**

Puppeteer requires additional system dependencies. You must add **`puppeteer`** to the [`APT`](/en/configurations/discloud.config/apt.md) field in your [**`discloud.config`**](/en/configurations/discloud.config.md) file.

<pre class="language-ini" data-title="discloud.config"><code class="lang-ini"><a data-footnote-ref href="#user-content-fn-1"># ...</a>
APT=tools, puppeteer
# ...
</code></pre>

***

## ⚙️ **Configuring Puppeteer**

Since **Puppeteer runs in a containerized environment**, you must add the `--no-sandbox` argument to ensure it works correctly.

```javascript
const puppeteer = require("puppeteer");

(async () => {
    const browser = await puppeteer.launch({
        args: ["--no-sandbox"]
    });

    const page = await browser.newPage();
    await page.goto("https://example.com");

    console.log(await page.title());
    await browser.close();
})();
```

{% hint style="info" %}

#### **Why `--no-sandbox`?**

Running Puppeteer inside a container **requires disabling the sandbox** to prevent security restrictions from blocking execution.
{% endhint %}

***

## ⚙️ **Using Puppeteer with `whatsapp-web.js`**

Since [**`whatsapp-web.js`**](https://wwebjs.dev/) also uses **Puppeteer** for QR code generation and background interactions, you must **include `--no-sandbox`** in its configuration.

```javascript
const { Client } = require("whatsapp-web.js");

const client = new Client({
    puppeteer: {
        args: ["--no-sandbox"],
    }
});

client.initialize();
```

{% hint style="info" %}

#### **Troubleshooting QR Code Issues:**

* If the **QR code does not appear** in Discloud logs, **increase the allocated RAM**.
* The more complex your interactions with WhatsApp, **the more RAM Puppeteer will need** to function properly.
  {% endhint %}

[^1]: **Note:** The **`...`** only indicate the continuation of other previous or subsequent options that are not relevant to mention on this page.


---

# 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.discloud.com/en/configurations/puppeteer.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.
