All Projects → whoisryosuke → nextjs-redux-authentication-boilerplate

whoisryosuke / nextjs-redux-authentication-boilerplate

Licence: other
NextJS app with Redux based authentication (via OAuth2).

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to nextjs-redux-authentication-boilerplate

Next Auth
Authentication for Next.js
Stars: ✭ 8,362 (+21905.26%)
Mutual labels:  oauth2, nextjs
Void
Fast and elegant file hosting service.
Stars: ✭ 48 (+26.32%)
Mutual labels:  nextjs
basil
An experimental Magento 2 theme
Stars: ✭ 18 (-52.63%)
Mutual labels:  nextjs
wodle
Static site generator using next and tachyons
Stars: ✭ 29 (-23.68%)
Mutual labels:  nextjs
next-and-cypress-example
Next.js example instrumented for code coverage from Cypress tests
Stars: ✭ 111 (+192.11%)
Mutual labels:  nextjs
next-ecommerce
A beautiful ecommerce made with Next.js
Stars: ✭ 184 (+384.21%)
Mutual labels:  nextjs
sage-next
familiar-zebra.surge.sh
Stars: ✭ 18 (-52.63%)
Mutual labels:  nextjs
Flask-Discord
Discord OAuth2 extension for Flask. An Easier implementation of "Log In With Discord".
Stars: ✭ 123 (+223.68%)
Mutual labels:  oauth2
web-starter-kit
An opinionated starter kit with styled-system, graphql-hooks, mobx and nextjs (PWA)
Stars: ✭ 17 (-55.26%)
Mutual labels:  nextjs
GITGET
GitHub의 Contributions를 iOS의 Widget으로 보여주는 App
Stars: ✭ 101 (+165.79%)
Mutual labels:  oauth2
saleor-storefront
A GraphQL-powered, NextJs-based, PWA storefront for Saleor. IMPORTANT: This project is [DEPRACETED] in favor of saleor/react-storefront soon to become our default demo and storefront starter pack.
Stars: ✭ 765 (+1913.16%)
Mutual labels:  nextjs
next-utils
🥩 🍳 A set of Next.js HoC utilities to make your life easier
Stars: ✭ 30 (-21.05%)
Mutual labels:  nextjs
nextjs-blog-starter-kit
NextJS Blog + Contentful Typescript Starter kit with Static Export 🚀
Stars: ✭ 56 (+47.37%)
Mutual labels:  nextjs
werther
An Identity Provider for ORY Hydra over LDAP
Stars: ✭ 103 (+171.05%)
Mutual labels:  oauth2
Kobra
Kobra is a visual programming language (like Scratch) for Machine Learning (currently under active development).
Stars: ✭ 223 (+486.84%)
Mutual labels:  nextjs
faeshare
MERN based social media web app made with the help of Next.js, Socket.io and TailwindCSS.
Stars: ✭ 37 (-2.63%)
Mutual labels:  nextjs
said-hayani-nextjs
Said Hayani personal blog built with NextJs
Stars: ✭ 17 (-55.26%)
Mutual labels:  nextjs
adeolaadeoti-v2
The second iteration of my portfolio
Stars: ✭ 67 (+76.32%)
Mutual labels:  nextjs
RocketLaunches
Rocket launches, a simple site to let you know what is the next rocket launch.
Stars: ✭ 13 (-65.79%)
Mutual labels:  nextjs
jeffjadulco.com
👽 Personal website running on Next.js
Stars: ✭ 54 (+42.11%)
Mutual labels:  nextjs

NextJS Redux Authentication Boilerplate

Shows how to use NextJS with Redux to create an authenticated web app that uses an OAuth2 API. This is essentially a fork of the NextJS Redux example, with redux-persist and authentication implemented.

There is some minimal use of Material UI. Feel free to drop it out and just use regular elements. This is also ready with next-css so you can import any CSS file into your component 👍

Highlights

  • The use of compose() from 'recompose/compose' to combine multiple component HOCs like connect(), and Material UI's withStyles().
  • Redux state is persisted by redux-perist
  • Example of dynamic routing and passing URL params in server.js

How it works

Redux + Redux-Persist

The way NextJS renders content is by using "page" components from the pages directory, and placing them in a wrapper component, as well as rendering them into a document (react-dom style). And Redux requires you to wrap your application in a Provider using React's Context API, and which you later connect your components to using Consumers.

The way we wrap our app in NextJS is by creating a _app.js file in the pages directory. Here we use render props to pass through our route component that's getting rendered with it's props. And in that render prop component, we can add wrap any other components around our route/page - like our Redux store -- and our <PersistGate> from redux-persist that holds our app in place until the Redux store is rehydrated. The <PersistGate> accepts a Loading component that displays while the app is rehydrating the store, I left it null.

Authentication

There are Redux actions, reducers, and constants in place for all the necessary Authentication services (logging in a user, logging out, etc). This was based off the react-redux-registration-login-example-master by Jason Watmore. When the user is logged in by dispatching the login action (dispatch(userActions.login(username, password));), whatever user data is transferred by the API as a response is stored in the Redux store under authentication.user.

Stack

  • NextJS
  • ReactJS
  • Redux
  • NodeJS
  • Express
  • Isomorphic-Fetch (for SSR API calls)

Development

npm run dev

Deploys an Express server, configured in the server.js file in project root, and builds the project using Next.

I highly recommend getting the Redux DevTools extension to browse the Redux store and state changes easily.

Admin / Organizer Access

This app uses JWT-style authentication and expects an access token that gets stored in localStorage and Redux for use in authenticated API calls later (through Redux actions or otherwise).

This is currently designed to use Laravel's Passport OAuth2 API, but it can be fit to any API that sends back a token.

Spin up a development server, create a new account, and use those login details in this app. AuthService class assumes dev server is located at http://localhost/, but also accepts any URL when you make a "new" class (new AuthService('http://localhost:4849')). See the seshsource-api repo for more details.

Deployment

npm run build

Todo

  • [] - Redux implemented with NextJS
  • [] - Redux store persisted across reloads (redux-persist)
  • [] - Dynamic routing using Express
  • [] - Login Authentication using OAuth2.0 / JWT tokens
  • [] - Protected/Authenticated Routes using HOCs (supporting SSR!)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].