How to set max viewport in Puppeteer with JavaScript?

Sometimes, we want to set max viewport in Puppeteer with JavaScript.

In this article, we’ll look at how to set max viewport in Puppeteer with JavaScript.

How to set max viewport in Puppeteer with JavaScript?

To set max viewport in Puppeteer with JavaScript, we call puppeeter.launch with an object that sets the defaultViewport option.

For instance, we write

const browser = await puppeteer.launch({ defaultViewport: null });

to set defaultViewport to null to make Puppeteer open a window bigger than 800px x 600px.

Conclusion

To set max viewport in Puppeteer with JavaScript, we call puppeeter.launch with an object that sets the defaultViewport option.