Simplified Userflow.js installation

Technical post: This post is intended for our developer users.

The recommended way of installing Userflow.js, via the userflow.js npm package, is now much easier than before.

Before, you had to call loadUserflow() first, and then wait to get the userflow object back from the returned Promise. Besides not being perfectly ergonomic, this is problematic if different parts of your app needs to access it.

Now, the module exports a userflow object as its default export, which you can use synchronously. It'll automatically inject the real Userflow.js (from our CDN) into the current page, and queue all method calls.

Before:

import {loadUserflow} from 'userflow.js'

loadUserflow().then(userflow => {
  userflow.init('...')
  userflow.identify('...')
})

Now:

import userflow from 'userflow.js'

userflow.init('...')
userflow.identify('...')

Note that the real Userflow.js won't be loaded until you call one of the userflow object's methods. This way you still have complete control over when Userflow.js actually loads.

See full docs on npm