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

@quiltt/react

v3.6.5

Published

React components and hooks for Quiltt Connector

Downloads

1,869

Readme

@quiltt/react

npm version CI

@quiltt/react provides React Components and Hooks for integrating Quiltt into React-based applications.

Installation

$ npm install @quiltt/react
# or
$ yarn add @quiltt/react
# or
$ pnpm add @quiltt/react

Core Modules and Types

The @quiltt/react library ships with @quiltt/core, which provides an Auth API and essential functionality for building Javascript-based applications with Quiltt. See the Core README for more information.

React Components

All components automatically handle Session token management under the hood, using the useQuilttSession hook.

To pre-authenticate the Connector for one of your user profiles, make sure to set your token using the QuilttProvider provider or the useQuilttSession hook. See the Authentication guides for how to generate a Session.

QuilttButton

Launch the Quiltt Connector as a pop-out modal.

By default, the rendered component will be a <button> element, but you can supply your own component via the as prop. You can also pass forward any props to the rendered component.

Example

import { useState } from 'react'
import { QuilttButton } from '@quiltt/react'

export const App = () => {
  const [connectionId, setConnectionId] = useState<string>()
  const handleExitSuccess = (metadata) => {
    setConnectionId(metadata?.connectionId)
  }

  return (
    <QuilttButton
      connectorId="<CONNECTOR_ID>"
      onExitSuccess={handleExitSuccess}
      className="my-css-class"
      styles={{ borderWidth: '2px' }}
      // ... other props to pass through to the button
    >
      Add Account
    </QuilttButton>
  )
}
export default App

QuilttContainer

Launch the Quiltt Connector inside a container.

By default, the rendered component will be a <div> element, but you can supply your own component via the as prop. You can also pass forward any props to the rendered component.

Example
import { useState } from 'react'
import { QuilttContainer } from '@quiltt/react'

export const App = () => {
  const [connectionId, setConnectionId] = useState<string>()
  const handleExitSuccess = (metadata) => {
    setConnectionId(metadata?.connectionId)
  }

  return (
    <QuilttContainer
      connectorId="<CONNECTOR_ID>"
      onExitSuccess={handleExitSuccess}
      className="my-css-class"
      styles={{ height: '100%' }}
      // ... other props to pass through to the container
    />
  )
}

export default App

QuilttProvider

A provider component for passing Session and settings down to the rest of your application.

Example

import { QuilttProvider } from '@quiltt/react'

const Layout = ({ children }) => {
  return <QuilttProvider token="{SESSION_TOKEN}">{children}</QuilttProvider>
}

export default Layout

React Hooks

For maximum control over the lifecycle of Quiltt Connector and Quiltt Sessions, you can also use hooks directly.

useQuilttConnector

A hook to manage the lifecycle of Quiltt Connector.

Example

import { useQuilttConnector } from '@quiltt/react'

const App = () => {
  const { open } = useQuilttConnector('<CONNECTOR_ID>', {
    onEvent: (type) => console.log(`Received Quiltt Event: ${type}`)
    onExitSuccess: (metadata) => console.log("Connector onExitSuccess", metadata.connectionId),
  })

  return(
    <button onClick={open}>
      Launch Connector
    </button>
  )
}

useQuilttSession

A hook to manage the lifecycle of Quiltt Sessions.

See the Authentication guides for more information.

Example

import { useCallback, useEffect } from 'react'

import { useQuilttSession } from '@quiltt/react'

const App = () => {
  const { session, importSession, revokeSession } = useQuilttSession()

  useEffect(() => {
    // Import session from API call, local storage, query param, etc.
    importSession('{SESSION_TOKEN}')
  }, [importSession])

  const logOut = useCallback(() => {
    // Revoke and clear the Quiltt session
    revokeSession()

    // do other stuff!
  }, [revokeSession])

  if (session) {
    console.log('Session token: ', session.token)
  } else {
    console.log('No Session available')
  }

  return (
    <>
      <div>Hello world!</div>
      <button onClick={logOut}>Log Out</button>
    </>
  )
}

export default App

Typescript support

@quiltt/react is written in Typescript and ships with its own type definitions. It also ships with the type definitions from @quiltt/core.

License

This project is licensed under the terms of the MIT license. See the LICENSE file for more information.

Contributing

For information on how to contribute to this project, please refer to the CONTRIBUTING.md file.