Single page applications

Use this installation guide if your website is a single page application or otherwise renders HTML with Javascript.

Step 1 is to copy and paste the following snippet into all pages you want Notifly to appear on. This would usually be your template for your application (an HTML file). The snippet should be placed right before the </body> tag:


Step 2 Is to call window.Notifly('init', ...) as shown below when the element with the ID elementId has been rendered:

window.Notifly('init', {
  authCode: "<USER_NOTIFLY_HASH>",
  externalId: "<EXTERNAL_USER_ID>"

React example

In React calling window.Notifly('init', ...) would be done as follows.

In the component that the Notifly icon should appear in, add a useEffect -hook similar to this:

const NotiflyWrapper = ({ user }) => {
  useEffect(() => {
    if (window.Notifly) {
      window.Notifly('init', {
        appId: "<YOUR_NOTIFLY_APP_ID>",
        authCode: "<USER_NOTIFLY_HASH>", // e.g. could be `user.notiflyId` here
        elementId: "notifly-wrapper",
        externalId: "<EXTERNAL_USER_ID>"// e.g. could be `` here
  }, [window.Notifly]) // add `user` here if required

  return <div id="notifly-wrapper" />

Last updated