# @exobase/use-basic-auth

> Exobase basic authentication hook

Latest version **1.0.0-rc.31** (published 2024-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install @exobase/use-basic-auth
pnpm add @exobase/use-basic-auth
yarn add @exobase/use-basic-auth
bun add @exobase/use-basic-auth
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0-rc.31 |
| Published | 2024-07-08 |
| First published | 2022-10-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 17.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | rayepps |
| Maintainers | rayepps |

## Links

- npm: https://www.npmjs.com/package/@exobase/use-basic-auth
- npm.io page: https://npm.io/package/@exobase/use-basic-auth

## Dependencies (1)

- [@exobase/core](https://npm.io/package/@exobase/core.md) ^1.0.0-rc.31

## Recent versions

- 1.0.0-rc.31 (latest) — 2024-07-08
- 1.0.0-rc.30 — 2024-02-21
- 1.0.0-rc.29 — 2024-02-20
- 1.0.0-rc.28 — 2024-02-19
- 1.0.0-rc.27 — 2024-02-19
- 1.0.0-rc.25 — 2023-03-07
- 1.0.0-rc.24 — 2023-03-02
- 1.0.0-rc.23 — 2023-03-01
- 1.0.0-rc.22 — 2023-03-01
- 1.0.0-rc.21 — 2023-02-22
- 1.0.0-rc.20 — 2023-02-22
- 1.0.0-rc.19 — 2023-01-08
- 1.0.0-rc.18 — 2023-01-07
- 1.0.0-rc.17 — 2023-01-03
- 1.0.0-rc.16 — 2023-01-03
- … 14 more at https://npm.io/package/@exobase/use-basic-auth/versions

## README

---
title: 'useBasicAuth'
description: 'A basic authentication hook'
group: 'Hooks'
badge: 'Auth'
---

Provides a Exobase hook function that will parse out the client id and client secret of an incoming request

_NOTE: This hook does not validate the values it parses, you'll need to do that on your own_

## Install

```sh
yarn add @exobase/use-basic-auth
# or
yarn add @exobase/hooks
```

## Import

```ts
import { useBasicAuth } from '@exobase/use-basic-auth'
// or
import { useBasicAuth } from '@exobase/hooks'
```

## Usage

You can use `useBasicAuth` to parse the client id and client secret from the request. You'll need to validate them yourself.

```ts
import { compose } from 'radash'
import type { Props } from '@exobase/core'
import { useNext } from '@exobase/use-next'
import { useBasicAuth, BasicAuth } from '@exobase/use-basic-auth'

export const securePingEndpoint = async ({
  auth
}: Props<{}, {}, BasicAuth>) => {
  console.log(auth) // { clientId: 'abc', clientSecret: 'abc' }
  return {
    message: 'pong'
  }
}

export default compose(useNext(), useBasicAuth(), securePingEndpoint)
```

In order to keep auth logic out of your endpoints you'll probably want to create a custom hook function to validate

---
_Source: https://npm.io/package/@exobase/use-basic-auth · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
