react-redux-auth0-kit

授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发、 常用JavaScript包
软件类型 开源软件
地区 不详
投 递 者 金珂
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

React Redux Auth0 Kit

Minimal starter boilerplate project with React, Redux, React Router and Auth0 authentication

Live demo

A live demo of this project with a simple Facebook login via Auth0 is available here: https://react-redux-auth0.firebaseapp.com.

Getting started

First create an auth0 account. Then run the following commands. Make sure your src/utils/config.js file has the correct values from your auth0 account.

# Install dependencies
npm install

# Copy configuration and replace with your own
cp src/utils/config.example.js src/utils/config.js

# Run
npm start

Open http://localhost:3000 to see the app running.

Features

Auth0

Auth0 helps you to:

  • Add authentication with multiple authentication sources, either social like Google, Facebook, Microsoft Account, LinkedIn, GitHub, Twitter, Box, Salesforce, among others, or enterprise identity systems like Windows Azure AD, Google Apps, Active Directory, ADFS or any SAML Identity Provider.
  • Add authentication through more traditional username/password databases.
  • Add support for linking different user accounts with the same user.
  • Support for generating signed Json Web Tokens to call your APIs and flow the user identity securely.
  • Analytics of how, when and where users are logging in.
  • Pull data from other sources and add it to the user profile, through JavaScript rules.

AuthService

The library auth0-lock provides the user authentication, and I also have a src/utils/AuthService.js module to wrap this Lock Widget usage and manage the localStorage items.

I'm using the latest Auth0 Lock 10 version in popup mode, which means here's the flow:

  • ->Login widget shows login panel
  • ->Redirect to auth0 to check login creds (done in hidden iframe)
  • ->Redirect back to localhost:3000/callback (done in hidden iframe)
  • ->AuthService waits for 'authenticated' event to fire
  • ->Redirects back to homepage

Libraries

This starter kit is minimal, only the strict necessary is added.

Library Description
react Facebook's library for building user interfaces 
redux State container for JavaScript apps
react-router Declarative routing for React apps using navigational components
create-react-app All tooling needed for react apps

The starter kit includes a working example app that puts all of the above to use.

Development

create-react-app takes care of tooling, development server, live reload, building, testing.

HMR is unfortunately not enabled during development, because create-react-app doesn't support it.

If you wish to directly use Webpack instead of create-react-app, you can eject any time by running npm run eject. Read here for more information about ejecting.

Testing

npm run lint to check linting errors. This projects follows eslint-config-react-app style.

npm test to run all tests. This project uses jest to run tests, and enzyme for unit testing React components.

Deployment

Out of the box, this starter kit is deployable by serving the ~/build folder generated by npm run build.

License

MIT. See LICENSE file.

Future ideas

  • Add a side effects library (redux-saga, redux-observable) to manage side effects. It makes the code more redux-compliant, however it goes against minimalism.
  • Any other ideas are welcome! Just post an issue.

Donations

If you like this project, I would really appreciate small donations. Here's my Ethereum address: 0xa395447BF15f7525484C0378c76627D45ADE0B96.

  • React-redux 7.1发版啦。 因为在新的项目中用到了hooks,但是用的时候react-redux还处于alpha.x版本的状态。用不了最新的API,感觉不是很美妙。好在,这两天发布了7.1版本。 现在来看看怎么用这个新的API。 useSelector() const result : any = useSelector(selector : Function, equalityFn?

  • react-hooks 是 react 官方新的编写推荐,我们很容易在官方的 useReducer 钩子上进行一层很简单的封装以达到和以往 react-redux \ redux-thunk \ redux-logger 类似的功能,并且大幅度简化了声明。 安装 安装 react-hooks-redux, 需要 react 版本 >= 16.7 yarn add react-hooks-redux

  • // npm install --save redux-actions 1:作用: 当我们的在开发大型应用的时候,对于大量的action,我们的reducer需要些大量的swich来对action.type进行判断。 redux-actions可以简化这一烦琐的过程,它可以是actionCreator,也可以用来生成reducer, 其作用都是用来简化action、reducer。 主要函数有cr

  • Redux 状态管理器 集中式管理应用中的状态数据,以一种可预测的方式更新状态数据 react-redux 绑定库官网 redux 与 react 没有任何直接关系,所以在 react 中要使用 redux 进行状态管理,通常还需要额外的绑定库:react-redux 概念 store:仓库,是一个容器,主要用于集中管理应用中的状态 state:状态,是各组件需要共享的状态数据 action:是一

 相关资料
  • 目录 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 为何组件频繁的重新渲染? 怎样使 mapStateToProps 执行更快? 为何不在被连接的组件中使用 this.props.dispatch ? 应该只连接到顶层组件吗,或者可以在组件树中连接到不同组件吗? React Redux 为何组件没有被重新渲染、或者 mapStateToProps 没有运行? 目前来看,

  • Universal React Redux Boilerplate A universal React/Redux boilerplate with sensible defaults. Out of the box, thisboilerplate comes with: Server-side rendering with Express Code splitting with dynamic

  • React-Redux-Enterprise A React-Redux boilerplate for enterprise web applications. Before you start with this boilerplate, please take a few minutes to read this article and see if you really need this

  • Live redux-react-starter This repository contains the minimal app to get started with redux, react, hot-reloading, async function and some other great stuffs. How to yarn 0.18+ must be present on your

  • React/Redux Links Curated tutorial and resource links I've collected on React, Redux, ES6, and more, meant to be a collection of high-quality articles and resources for someone who wants to learn abou

  • React Redux Saucepan A minimal Universal React redux JS stack using Flow, with hot reloading, linting and server-side rendering. This is a universal react project. It provides server-side rendering an