Skip to content

p3ol/react-access

 
 

Repository files navigation

CI

Poool Access - React SDK

The easiest way to add Poool Access to your React app ✨

Installation

yarn add @poool/react-access

Usage

import React from 'react';
import { PaywallContext, RestrictedContent, Paywall } from '@poool/react-access';

export default () => (
  { /* Wrap everything with our PaywallContext component */ }
  <PaywallContext appId="insert_your_app_id" config={{ cookies_enabled: true }}>

    { /* Wrap your content with our RestrictedContent component */ }
    <RestrictedContent>
      <div className="articleBody">
        <p>Your article content</p>
      </div>
    </RestrictedContent>

    { /* Place our paywall element where you want your paywall to be displayed */ }
    <Paywall
      pageType="premium"
      beforeInit={poool => {
        poool('config', 'debug', true);
      }}
    />
  </PaywallContext>
);

IE Compatibility

As part of a global effort to deprecate Internet Explorer, we decided not to include IE polyfills by default. You can still manually import a version containing all the necessary polyfills for IE >= 11:

import * as PooolReactAccess from '@poool/react-access/dist/ie/esm';

Please note that this build will probably add more than 150kb to your final bundle.

Documentation

<PaywallContext />

Props

<RestrictedContent />

Props

No custom props

<Paywall />

Props

usePoool()

Can be used to retrieved some properties from the current paywall context, as well as the Poool SDK itself.

Returns

  • poool {Function} The entire poool library
  • appId {String} Current app ID
  • config {Object} Context config
  • texts {Object} Context texts
  • styles {Object} Context styles

Example

const { poool, appId } = usePoool();
poool && poool('init', appId);

Contributing

Please check the CONTRIBUTING.md doc for contribution guidelines.

Development

Install dependencies:

yarn install

Run examples at http://localhost:63000/ with webpack dev server:

yarn serve

And test your code:

yarn test

License

This software is licensed under MIT.

Contributors

Ugo Stephant
Ugo Stephant
💻 📖 🔧
Simon Deflesschouwer
Simon Deflesschouwer
🔧

About

⚛️ The easiest way to add Poool Access to your React app

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 9