Categories
JavaScript Answers

How to set max viewport in Puppeteer?

Spread the love

Sometimes, we want to set max viewport in Puppeteer.

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

How to set max viewport in Puppeteer?

To set max viewport in Puppeteer, we set the defaultViewport option to null.

For instance, we write

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

to call puppeteer.luanch with an object that has defaultViewport set to null.

This will make Puppeteer launch with the max viewport resolution instead of 800×600.

Conclusion

To set max viewport in Puppeteer, we set the defaultViewport option to null.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *