Exobase
  1. Auth
  2. useTokenAuth

Provides an Exobase hook to parse and validate a JWT token in a request. It also includes a utility for generating JWT tokens.

Install

yarn add @exobase/use-token-auth
# or
yarn add @exobase/hooks

Import

import { useTokenAuth } from '@exobase/use-token-auth'
// or
import { useTokenAuth } from '@exobase/hooks'

Usage

import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useTokenAuth } from '@exobase/use-token-auth'

const endpoint = (props: Props) => {
  console.log(props)
}

export default compose(
  useExpress(),
  useTokenAuth({
    type: 'id',
    secret: 'my-little-secret'
  }),
  endpoint
)