0.1.41 • Published 8 months ago

react-pod-connector v0.1.41

Weekly downloads
-
License
MIT
Repository
-
Last release
8 months ago

React Pod Connector

A simple login (with Solid) flow for React applications.

Demo

✅ Recommended & Custom Identity Provider Logins ✅ Customizable app logo and name ✅ Can be triggered manually (per-page) or automatically ✅ Allows users to save login info for future logins ✅ Dark Mode (lol)

Overview | Usage | Reference

Overview

This library is designed for you to save time when you start building a new Solid application in React.

In it's default configuation it will show a Solid logo and give popular options for Identity Providers like Inrupt's ESS or the Solid Community's NSS, as well as the option to enter a custom IDP login URL (with or without https://).

The component also allows users to easily save login info for the future.

Usage

Use yarn add react-pod-connector or npm install react-pod-connector to install.

You can wrap your entire app in this component to always automatically connect users with their pods:

// App.tsx
import { PodConnector } from "react-pod-connector"

function App() {
  return (
    <PodConnector>
      <div>Hello World</div>
    </PodConnector>
  )
}

Or you can manually trigger the login flow on private pages by adding a route "middleware" to your react router configuration:

// PrivateRoute.tsx
import { useConnect } from "react-pod-connector"

interface PrivateRouteProps {
  page: JSX.Element
}

export const PrivateRoute: React.FC<PrivateRouteProps> = ({ page }) => {
  const { session } = useConnect()

  if (session) {
    return page
  } else {
    return <></>
  }
}
// App.tsx
import PrivateRoute from "./PrivateRoute"

const routes = [
  {
    path: "/",
    element: <div>Hello World! This is a public page</div>,
  },
  {
    path: "/private",
    element: (
      <PrivateRoute page={<div>Hello World! This is a private page</div>} />
    ),
  },
]

function App() {
  const router = createBrowserRouter(routes)

  return (
    <PodConnector auto={false}>
      <RouterProvider router={router} />
    </PodConnector>
  )
}

Reference

These are all the customizable props and their defaults: | name | default | description | | ------ | ------ | ------ | | auto | true | Determines whether the component automatically logs in users or waits for the flow to be triggered | | name | Solid Login | The display name of the application | | logo | Logo of the Solid project | The logo that is displayed | | lead | Choose an identity provider for this Solid application | The text that is displayed on top of the login form | | loadingIndicator | - | The loading indicator that is shown when the page first loads or when a session is being restored. | | recommendedLogins | ["https://login.inrupt.com", "https://solidcommunity.net"] | A list of login options that are presented to the user as "recommended" | | loginOptions | null | The login options with which to call the login function (see Inrupt's documentation). |

0.0.40

8 months ago

0.0.41

8 months ago

0.0.42

8 months ago

0.1.11

8 months ago

0.0.43

8 months ago

0.1.12

8 months ago

0.0.44

8 months ago

0.1.13

8 months ago

0.0.45

8 months ago

0.1.14

8 months ago

0.0.37

8 months ago

0.0.38

8 months ago

0.0.39

8 months ago

0.1.41

8 months ago

0.0.30

8 months ago

0.0.31

8 months ago

0.0.32

8 months ago

0.0.33

8 months ago

0.0.34

8 months ago

0.0.35

8 months ago

0.0.36

8 months ago

0.1.40

8 months ago

0.1.0

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.38

8 months ago

0.1.8

8 months ago

0.0.26

8 months ago

0.1.39

8 months ago

0.1.7

8 months ago

0.0.28

8 months ago

0.0.29

8 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.6

8 months ago

0.1.5

8 months ago

0.1.30

8 months ago

0.1.31

8 months ago

0.1.32

8 months ago

0.1.33

8 months ago

0.0.21

8 months ago

0.1.34

8 months ago

0.0.22

8 months ago

0.1.35

8 months ago

0.1.36

8 months ago

0.0.24

8 months ago

0.1.37

8 months ago

0.0.25

8 months ago

0.1.29

8 months ago

0.0.17

8 months ago

0.0.18

8 months ago

0.0.19

8 months ago

0.1.20

8 months ago

0.1.21

8 months ago

0.1.22

8 months ago

0.1.23

8 months ago

0.1.25

8 months ago

0.1.26

8 months ago

0.1.16

8 months ago

0.1.17

8 months ago

0.1.18

8 months ago

0.1.19

8 months ago

0.0.16

9 months ago

0.0.15

11 months ago

0.0.14

11 months ago

0.0.13

11 months ago

0.0.12

11 months ago

0.0.11

11 months ago

0.0.9

11 months ago

0.0.8

11 months ago

0.0.7

11 months ago

0.0.6

11 months ago

0.0.5

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago