Skip to content

A session provider with routing handled class (POC) I made for ReactCBA

Notifications You must be signed in to change notification settings

niconiahi/class-session-provider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a POC for basic private (protected) routes and public route. With custom hooks to control login and logout events

This includes:

A provider for handling the user session, in sync with localStorage: <SessionProvider />
Custom Route components: <ProtectedRoute /> and <PublicRoute />
Two custom hooks: useLogin() and useLogout()
A form with validation featuring Formik and Yup: <Login />
Some scafolding I like to use
Some helpers

Libraries used:

  • Formik
  • React
  • React Router Dom
  • Yup

Language:

  • Typescript

Application tree:

.
├── components
│   ├── Home.tsx
│   └── Login.tsx
├── lib
│   ├── hooks
│   │   ├── useLogin.ts
│   │   └── useLogout.ts
│   ├── providers
│   │   └── SessionProvider
│   │       ├── context.ts
│   │       └── provider.tsx
│   ├── constants.tsx
│   ├── helpers.ts
│   ├── router.tsx
│   ├── routes.ts
│   └── types.ts
├── index.css
├── index.tsx
└── react-app-env.d.ts

Hope you enjoy it!

About

A session provider with routing handled class (POC) I made for ReactCBA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published