Code Monkey home page Code Monkey logo

crossplatformsweden / react-native-cross-cognito Goto Github PK

View Code? Open in Web Editor NEW
3.0 4.0 0.0 448 KB

React-Native implementation of AWS Cognito and Amplify SDK including login screens

Home Page: https://aws.amazon.com/cognito/

License: Apache License 2.0

JavaScript 7.09% TypeScript 91.76% Shell 1.15%
javascript typescript react-native aws-cognito aws-cognito-react amplify aws-amplify aws-amplify-react-native login authentication crossplatform

react-native-cross-cognito's Introduction

Crossplatform

Crossplatform React-Native Cognito

React-Native implementation of AWS Cognito and Amplify SDK including login screens

Install

This package makes use of our react-native-cross-components that are based on on react-native-paper. Paper which is therefore a peer dependency.

Native

Install with aws amplify and link it.

	npm i react-native-vector-icons
	npm i aws-amplify
	npm i react-native-paper
	npm i react-native-cross-cognito

	# one liner
	npm i react-native-vector-icons aws-amplify react-native-paper react-native-cross-cognito
	yarn add react-native-vector-icons
	yarn add aws-amplify
	yarn add react-native-paper
	yarn add react-native-cross-cognito

	# one liner
	yarn add react-native-vector-icons aws-amplify react-native-paper react-native-cross-cognito

Expo prev CRNA

	npm i react-native-cross-cognito
	yarn add react-native-cross-cognito

Documentation

See our GitHub Pages generated from code comments. This documentation is also available as intellisense / auto complete.

See Components below for examples


npm npm Build status GitHub

codecov dependencies peer dependencies Prettier

aws-amplify react-native-cross-components

GitHub forks GitHub stars GitHub watchers Twitter Follow

Table of Contents

Table of contents generated with markdown-toc

Services and helpers

GetJwtToken

Gets the current user's Jwt token from AWS Cognito.

For documentation see API reference - GetJwtToken.

import { GetJwtToken } from 'react-native-cross-cognito';

const myToken = await GetJwtToken();

Components

CognitoLogin

Renders a complete login form using your Amplify token.

For properties and documentation, see API reference - Class CognitoLogin.

Examples

With success callback

	import { CognitoLogin } from 'react-native-cross-cognito';
	import amplify from './aws-exports';

	Amplify.configure(amplify);

	export const MyComp => () => (
		<CognitoLogin
			onRegisteredUser={(user) => {
				Alert.alert('Registration complete', 'Thank you ' + user.getUsername());
			}}
			onLoggedIn={(user) => {
				Alert.alert('Logged in', 'Welcome ' + user.getUsername());			}} />
	);

Set initial form

	import { CognitoLogin } from 'react-native-cross-cognito';
	import amplify from './aws-exports';

	Amplify.configure(amplify);

	export const MyComp => () => (
		<CognitoLogin activeForm='Register' />
	);

With button customizations

	import { CognitoLogin } from 'react-native-cross-cognito';
	import amplify from './aws-exports';

	Amplify.configure(amplify);

	export const MyComp => () => (
        <CognitoLogin
          buttonProps={{ mode: 'text' }}
          loginButtonProps={{ mode: 'contained', title: 'ENGAGE!' }}
          />
	);

With custom children

	import { CognitoLogin } from 'react-native-cross-cognito';
	import amplify from './aws-exports';

	Amplify.configure(amplify);

	export const MyComp => () => (
        <CognitoLogin
          registerChildren={
            <Text
              style={{
                color: 'blue',
                fontWeight: 'bold',
                margin: 10,
                fontSize: 16,
              }}
            >
              &lt;ENLIST NOW&gt;
            </Text>
          }
        >
          <Text
            style={{
              color: 'red',
              fontWeight: 'bold',
              margin: 10,
              fontSize: 16,
            }}
          >
            * &lt;WARNING: RESTRICTED AREA&gt; :)
          </Text>
        </CognitoLogin>
	);

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.