Local Development

Local Development

Create an account

Ensure you have created your account on ScreenGrab.cloud

https://screengrab.cloud/login (opens in a new tab)

Login, create a project and can get your api key.

https://screengrab.cloud/dashboard/projects (opens in a new tab)

Optional Local Development

To take screenshots of components on your local server, you'll need screengrab-server running locally.

💡

screengrab-server is a limited implmentation of screengrab.cloud suited for development and testing.

screen-server.js
const server = require("screengrab-server")
const PORT = process.env.PORT || 3000
server.listen(PORT, () => {
  console.log('Server listening on ', PORT)
})

start the server with

node screen-server.js 

server docs: https://github.com/screengrab-cloud/screengrab-server (opens in a new tab)

Add the screengrab server url to your config.

const { ScreenGrab } = reqire("screengrab.js")
 
const screengrab = ScreenGrab({
apiKey: 'your-api-key',
server: 'http://localhost:3031'
})
 
screengrab.url('http://localhost:3000').grab()
 .then(image => console.log('image url', image.url))