Skip to content

Auth Header

Get the Auth Header for future request from any Component simply by using HOC or Hooks

  • To get the Auth Header from Higher Order Components, use withAuthHeader
  • To get the Auth Header using React Hooks, use useAuthHeader

Using Hooks

import {useAuthHeader} from 'react-auth-kit'

Demo

import React from 'react'
import {useAuthHeader} from 'react-auth-kit'

const SomeComponent = () => {
    const authHeader = useAuthHeader()

    return(
        <div>
            {authHeader}
        </div>
    )
}

Using Higher Order Component

import {withAuthHeader} from 'react-auth-kit'

Demo

import React from 'react'
import {withAuthHeader} from 'react-auth-kit'

class SomeComponent extends React.Component {
    render(){
        return (
            <div>
                {this.props.authHeader}
            </div>
        )
    }
}

export default withAuthHeader(SomeComponent)

— 🔑 —

React Auth Kit is Apache 2.0 License code