@aioha/react-provider
TypeScript icon, indicating that this package has built-in type declarations

1.4.1 • Public • Published

Aioha React Provider

React provider for Aioha for React apps that are not using the ready-made UI.

This module is used and provided in the ready-made UI so there is no need to install this separately.

Installation

pnpm i @aioha/react-provider @aioha/aioha

Usage

  1. Initialize Aioha and setup provider at the root of your application. This may be in index.jsx, index.tsx or App.tsx depending on the framework you use.
import { initAioha } from '@aioha/aioha'
import { AiohaProvider } from '@aioha/react-provider'

// See options: https://aioha.dev/docs/core/usage#instantiation
const aioha = initAioha()

const App = () => {
  return (
    <AiohaProvider aioha={aioha}>
      <TheRestOfYourApplication />
    </AiohaProvider>
  )
}
  1. Use Aioha anywhere within AiohaProvider through useAioha().
import { useAioha } from '@aioha/react-provider'

export const AiohaPage = () => {
  const { aioha, user, provider, login, logout } = useAioha()

  // rest of your page goes here
}

Logins and logouts shall be performed using the login() and logout() method provided above, not aioha.login() or aioha.logout(). Logged in username and provider may be retrieved through user and provider variables.

/@aioha/react-provider/

    Package Sidebar

    Install

    npm i @aioha/react-provider

    Homepage

    aioha.dev

    Weekly Downloads

    20

    Version

    1.4.1

    License

    MIT

    Unpacked Size

    7.1 kB

    Total Files

    7

    Last publish

    Collaborators

    • techcoderx