The DOM package makes it easy to add Memberstack to any app that runs in a browser environment.
For additional functionality check out our Admin API & React Package
Coming from MS 1.0? Read this to learn how to Convert 1.0 front-end API code to 2.0 code
Install the Memberstack DOM package from the npm public registry, or yarn.
npm install @memberstack/dom
yarn add @memberstack/dom
<aside>
<img src="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5ba120e9-9b94-4345-8203-58f1896913ad/5cbcc29efad96cf6f89a0d61_Webflow-round.svg" alt="https://s3-us-west-2.amazonaws.com/secure.notion-static.com/5ba120e9-9b94-4345-8203-58f1896913ad/5cbcc29efad96cf6f89a0d61_Webflow-round.svg" width="40px" /> If you are using Webflow you will need to define a Memberstack variable. const memberstack = window.$memberstackDom
</aside>
After the package has been installed successfully, you can initialize the Memberstack instance by providing the initialization object.
import memberstackDOM from "@memberstack/dom";
const memberstack = memberstackDOM.init({
publicKey: "pk_...",
});
Besides passing the default initialization object values, the DOM package also allows you to pass a sessionDurationDays
field. This allows you to override the default amount of days that a session persists.
import memberstackDOM from "@memberstack/dom";
const memberstack = memberstackDOM.init({
publicKey: "pk_...",
sessionDurationDays: 7
});
The DOM package allows you to interact with Memberstack's login, signup, and forgot password modals, using the openModal
and hideModal
methods.