0.2.3 • Published 2 years ago

@taho2509/rock-common-ui v0.2.3

Weekly downloads
-
License
-
Repository
github
Last release
2 years ago

rock-common-ui

Common components to rock

Installation

Run the following command: npm install @taho2509/rock-common-ui

Use

After installing use it like:

import {BrowserRouter as Router, Routes, Route} from 'react-router-dom';
import {
  Login,
  Logout,
  RequireAuth,
  ProvideAuth,
} from '@taho2509/rock-common-ui';

function App() {
  return (
    <ProvideAuth>
      <Router>
        <Logout />
        <div>
          <Routes>
            <Route exact path="/" element={<Login pathname="/next" />} />
            <Route
              path="/next"
              element={
                <RequireAuth redirectTo="/">
                  <p>Welcome</p>
                </RequireAuth>
              }
            />
          </Routes>
        </div>
      </Router>
    </ProvideAuth>
  );
}

export default App;

Notes

  • The env var REACT_APP_CLIENT_ID with the google client id needs to be setted
  • The env var REACT_APP_BYPASS_LOGIN could be use for testing purposes as true
  • The Login component expects a pathname prop with the route to redirect on success