Categories
JavaScript Answers

How to set max viewport in Puppeteer with JavaScript?

Spread the love

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.

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 *