@botpoison/browser
Installation
NPM
NPM is the recommended installation method. It pairs nicely with module bundlers such as Webpack.
npm install @botpoison/browser
CDN
If you don't have access to NPM, you can download the latest version via a CDN.
markup
<script src="https://unpkg.com/@botpoison/browser" async></script>
Creating an instance
javascript
import Botpoison from "@botpoison/browser";const botpoison = new Botpoison({publicKey: "pk_xxxxxxxx"});
Processing a challenge
Basic
javascript
import Botpoison from "@botpoison/browser";const botpoison = new Botpoison({publicKey: "pk_xxxxxxxx"});const { solution } = await botpoison.challenge();
With progress callback
javascript
import Botpoison from "@botpoison/browser";const botpoison = new Botpoison({publicKey: "pk_xxxxxxxx"});const { solution } = await botpoison.challenge({onProgress: (progress) => {if(progress === 0.5) {console.log("Halfway there");}else if(progress === 1) {console.log("Finished");}}});
Manually / lazily initializing the library
This is particularly useful for SSR frameworks such as Next.js and Nuxt.js (where window may be undefined on the initial load).
javascript
import Botpoison from "@botpoison/browser";Botpoison.init()