shyntech-reactlib-auth

0.0.3 • Public • Published

shyntech-reactlib-auth

Made Vite Library Mode

NPM JavaScript Style Guide

Install

npm install --save shyntech-reactlib-auth;

Usage

import React, { Component } from 'react'
import {AuthPage, sendLogin} from 'shyntech-reactlib-auth'

class Example extends Component {
  render() {
    return <AuthPage sendLogin={sendLogin} baseURL={'http://localhost:3000'} loginEndpoint={'/auth/login'}  />
  }
}

.

Props

.

sendLogin: Function (required)

The component takes a request function. the library exports a default request function which can be imported with "import { sendLogin } from 'shyntech-reactlib-auth'". However, if you use this function, then you are required to provide the baseURL and loginEndpoint Props. You can however pass a custom function to make the request. Make sure you use the method "POST" since you are making a login request.

import {component} from 'react'
// your custom sendLogin function must be an async function
async function customSendLogin(data){
  // your code here
}

// in your JSX File
class Example extends Component {
  render() {
    // the props baseURL <string> and loginEndpoint <string> are required if you use the default login function as they tell the function the url where to send the request.
    return <AuthPage sendLogin={customSendLogin} />
  }
}

// usage for default sendLogin function
import {sendLogin} from 'shyntech-reactlib-auth'

class Example extends Component {
    render() {
        return <AuthPage sendLogin={sendLogin} baseURL={'http://localhost:3000'} loginEndpoint={'/auth/login'}/>
    }
}

The library calls the sendLogin function with the following arguments sendLogin(data,baseURL,loginEndpoint). But the baseURL and LoginEndpoint are only required if you are using the sendLogin function provided by the library.

.

baseURL: String

Base url to the server. Takes the format "https://myserveraddress.com", "http://localhost:3000" or any other server address

.

loginEndpoint: String

Login endpoint on the server . "/mypath/to/auth"

Alt text

License

MIT © Adefuye Abayomi

Readme

Keywords

none

Package Sidebar

Install

npm i shyntech-reactlib-auth

Weekly Downloads

1

Version

0.0.3

License

none

Unpacked Size

2.1 MB

Total Files

6

Last publish

Collaborators

  • yomi-daniel