@everfund/js-sdk
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

logo

Everfund Docs Github Action Test Status GitHub commit activity Follow on X

@everfund/js-sdk


Overview

Our core JavaScript library for building modern donation experiences. It provides components like checkout forms, subscription management, and donor profiles to help developers quickly integrate donation functionality into nonprofit websites and applications.

Getting Started

Installation

There are two ways you can include @everfund/js-sdk in your project. You can either import the @everfund/js-sdk npm module or load @everfund/js-sdk with a script tag.

Install everfund/js-sdk as ES module

pnpm i @everfund/js-sdk
# or
yarn add @everfund/js-sdk
# or
npm install @everfund/js-sdk
import everfund from '@everfund/js-sdk';

document?.getElementById('donate-modal')?.addEventListener('click', () => {
  console.log('launch Everfund Modal');
  everfund.donationWidget({
    code: '078f',
    onSuccess: function (onSuccessPayload) {
      console.log(onSuccessPayload);
    },
    onFailure: function (error) {
      console.log(error);
    },
    onClose: function () {
      //
      console.log('Closed Modal');
    },
  });
});

Install @everfund/js-sdk as script

Add the following script to your site's <body> element:

<script>
  {
    !(function (w, d, i, s) {
      function l() {
        if (!d.getElementById(i)) {
          var f = d.getElementsByTagName(s)[0],
            e = d.createElement(s);
          (e.type = 'text/javascript'),
            (e.async = !0),
            (e.src =
              'https://cdn.jsdelivr.net/npm/@everfund/js-sdk/dist/js-sdk.global.js'),
            f.parentNode.insertBefore(e, f);
        }
      }
      if ('function' != typeof w.Everfund) {
        var c = function () {
          c.q.push(arguments);
        };
        (c.q = []),
          (w.Everfund = c),
          'complete' === d.readyState
            ? l()
            : w.attachEvent
            ? w.attachEvent('onload', l)
            : w.addEventListener('load', l, !1);
      }
    })(window, document, 'everfund', 'script');
  }
</script>

Usage

<body>
  <div class="buttonContainer">
    <button data-ef-modal="j1q16MvJl5lqfji06bVFKei3HZkW">Donate Now</button>
  </div>
</body>

For further details and examples, please refer to our Documentation.

Build

To build the package locally with tsup, run:

pnpm build

Contributing

At Everfund, we strive to create an inclusive and welcoming environment for all contributors.

To ensure a productive and respectful experience for everyone involved, we have established a few ground rules.

Please review our Code of Conduct before getting started.

If you're new to the project, you may want to start with one of our designated "good first issues" These issues are specifically chosen to be accessible and easy to understand, making them a great introduction to the project.

Together, let's build something amazing!

Security

@everfund/js-sdk follows good practices of security, but 100% security cannot be assured.

@everfund/js-sdk is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

This project is licensed under the MIT license.

See LICENSE for more information.

Readme

Keywords

none

Package Sidebar

Install

npm i @everfund/js-sdk

Weekly Downloads

0

Version

3.0.1

License

MIT

Unpacked Size

104 kB

Total Files

17

Last publish

Collaborators

  • burnedchris