diff --git a/README.md b/README.md index 4d73f24..54e1de3 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,6 @@ Library to get started quickly with Auth0 using React and React-Router. -## Features - -* ✔︎ -* ✔︎ -* ✔︎ - ## Installation Install `react-router-auth0` via yarn or npm. @@ -18,7 +12,68 @@ $ yarn add react-router-auth0 ## Usage +Inside your router, add an `AuthProvider` and your routes. + +``` +import { + PrivateRoute, + LoginRoute, + LogoutRoute, + LandingPageRoute, + AuthCallbackRoute, + AuthProvider, +} from 'react-router-auth0' + +const authedRoutes = ( + + + + + + + + + + +) +``` + +And add it to your main router like this: +``` +const Router = () => { + return ( + + + + {authedRoutes} + + + + ) +} +``` + +### Component Descriptions: + +`AuthProvider`: Main component which will bootstrap you auth0 client. + +`PrivateRoute`: Any route the can only be accessed when logged in. If user is not logged in, redirects to the login route. + +`LoginRoute`: Takes you to the auth0 lock screen + +`LogoutRoute`: Handles auth0 logout and redirects you to the initial/landing page. + +`LandingPageRoute`: When hit, will display any url passed through `landingUrl` prop when the user is not logged in. This can be a separate app/page, with or without react, which gives you the option of having one plain html/css lightweight landing page. If the user is logged in, redirects to url passed through `loggedInPath` prop. + +`AuthCallbackRoute`: Route which Auth0 will callback once user logs in. Make sure to enable this url on your Auth0 management console. ## LICENSE -MIT \ No newline at end of file +MIT