GithubHelp home page GithubHelp logo

dmatora / react-wechat-login Goto Github PK

View Code? Open in Web Editor NEW

This project forked from philwu/react-wechat-login

0.0 0.0 0.0 261 KB

React component for website login by Wechat

License: MIT License

JavaScript 28.22% PHP 29.62% TypeScript 15.94% CSS 5.50% HTML 20.73%

react-wechat-login's Introduction

react-wechat-login

English | δΈ­ζ–‡

React component for website login by Wechat

Installation

$ npm install react-wechat-login

Usage

Frontend

import WechatLogin from "react-wechat-login";

const loginWechatRes = (res) => {
  console.log(res);
}

...
<WechatLogin
  appid={YOUR_APP_ID}
  redirectUri="http://localhost:4000/api/wechatlogin"
  onSuccess={loginWechatRes}
/>
...

Backend

**Important:**

In order to transfer the response message between iframe and parent page, the returned html from the backend must call the parent.postMessage(). Please check this example

Customize style of QR

Based on the document on the Wechat Open Platform, you can customize the style of the QR code image by providing the URI of your css file. That means you need to create a css file in the public folder and provide the URI to the css prop.

An example of css file is following:

.impowerBox .qrcode {
  width: 200px;
}
.impowerBox .title {
  display: none;
}
.impowerBox .info {
  width: 200px;
}
.status_icon {
  display: none;
}
.impowerBox .status {
  text-align: center;
}

Props

props require type description
appid YES string Your appid
redirectUri YES string Your redirect uri. It must be the same origin of the uri you set in the wechat open platform
onSuccess YES function the callback funciton after the login
state string the state sent back to the backend
style CSSProperties the style of the iframe element
css string the location of css file for customizing style of QR code

Welcome submit issues

https://github.com/philwu/react-wechat-login/issues

react-wechat-login's People

Contributors

philwu avatar dmatora avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.