npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@stripe/react-connect-js

v3.3.19

Published

React components for Connect.js and Connect embedded components

Downloads

227,245

Readme

@stripe/react-connect-js

React Connect.js

React components for Connect.js and Connect embedded components

This project is a thin React wrapper around Connect embedded components. It allows you to add embedded components to any React app, and manages the state and lifecycle of embedded components for you.

Note: Some Connect embedded components are currently still in preview. These can be viewed on our doc site, where you can also request preview access.

Components

The list of supported components and their required parameters can be found here

Minimal example

First, install React Connect.js and Connect.js.

npm install @stripe/react-connect-js @stripe/connect-js

You have to wrap your components with ConnectComponentsProvider in order to provide the ConnectInstance context to create or update components

Example

See more examples in the /examples folder

import React from 'react';
import ReactDOM from 'react-dom';
import {loadConnectAndInitialize} from '@stripe/connect-js';
import {
  ConnectPayments,
  ConnectPayouts,
  ConnectPaymentDetails,
  ConnectComponentsProvider,
} from '@stripe/react-connect-js';

const fetchClientSecret = async () => {
  // Fetch the AccountSession client secret by making an API call to your service
};
const connectInstance = loadConnectAndInitialize({
  publishableKey: '{{pk test123}}',
  fetchClientSecret: fetchClientSecret,
  appearance: {
    variables: {
      colorPrimary: '#228403', //optional appearance param,
    },
  },
});

const App = () => (
  <ConnectComponentsProvider connectInstance={connectInstance}>
    <ConnectPayments />
    <ConnectPayouts />
    <ConnectPaymentDetails
      onClose={() => {
        console.log('closed');
      }}
      payment="pi_test123"
    />
  </ConnectComponentsProvider>
);

ReactDOM.render(<App />, document.body);

The stripeConnect.initalize function returns a ConnectInstance once you initialize it with a publishable key and a client secret returned from the Account Session API call.

We’ve placed a placeholder API key in this example. Replace it with your actual publishable API keys to test this code through your Connect account.

Contributing

If you would like to contribute to React Connect.js, please make sure to read our contributor guidelines.