0.1.41 • Published 2 years ago

react-pod-connector v0.1.41

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years 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

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.1.11

2 years ago

0.0.43

2 years ago

0.1.12

2 years ago

0.0.44

2 years ago

0.1.13

2 years ago

0.0.45

2 years ago

0.1.14

2 years ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.1.41

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.1.40

2 years ago

0.1.0

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.38

2 years ago

0.1.8

2 years ago

0.0.26

2 years ago

0.1.39

2 years ago

0.1.7

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.30

2 years ago

0.1.31

2 years ago

0.1.32

2 years ago

0.1.33

2 years ago

0.0.21

2 years ago

0.1.34

2 years ago

0.0.22

2 years ago

0.1.35

2 years ago

0.1.36

2 years ago

0.0.24

2 years ago

0.1.37

2 years ago

0.0.25

2 years ago

0.1.29

2 years ago

0.0.17

2 years ago

0.0.18

2 years ago

0.0.19

2 years ago

0.1.20

2 years ago

0.1.21

2 years ago

0.1.22

2 years ago

0.1.23

2 years ago

0.1.25

2 years ago

0.1.26

2 years ago

0.1.16

2 years ago

0.1.17

2 years ago

0.1.18

2 years ago

0.1.19

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.13

2 years ago

0.0.12

2 years ago

0.0.11

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago