# gitbeaker-hooks

> React Hooks library for Gitbeaker.

Latest version **0.2.1** (published 2024-05-06) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install gitbeaker-hooks
pnpm add gitbeaker-hooks
yarn add gitbeaker-hooks
bun add gitbeaker-hooks
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.1 |
| Published | 2024-05-06 |
| First published | 2024-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 559.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ryohidaka |
| Maintainers | hidaka |
| Keywords | react, hooks, gitlab, gitbeaker |

## Links

- npm: https://www.npmjs.com/package/gitbeaker-hooks
- Repository: https://github.com/ryohidaka/gitbeaker-hooks
- Homepage: https://github.com/ryohidaka/gitbeaker-hooks#readme
- Issues: https://github.com/ryohidaka/gitbeaker-hooks/issues
- npm.io page: https://npm.io/package/gitbeaker-hooks

## Dependencies (2)

- [swr](https://npm.io/package/swr.md) ^2.2.5
- [@gitbeaker/rest](https://npm.io/package/@gitbeaker/rest.md) ^40.0.2

## Recent versions

- 0.2.1 (latest) — 2024-05-06
- 0.2.0 — 2024-04-11
- 0.1.3 — 2024-04-02
- 0.1.2 — 2024-03-31
- 0.1.1 — 2024-03-31
- 0.1.0 — 2024-03-31

## README

# gitbeaker-hooks

[![npm version](https://badge.fury.io/js/gitbeaker-hooks.svg)](https://badge.fury.io/js/gitbeaker-hooks)
![build](https://github.com/ryohidaka/gitbeaker-hooks/workflows/Build/badge.svg)
[![codecov](https://codecov.io/gh/ryohidaka/gitbeaker-hooks/graph/badge.svg?token=RHP9TB2F51)](https://codecov.io/gh/ryohidaka/gitbeaker-hooks)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B6TVH92)

## Overview

React Hooks library for [Gitbeaker](https://github.com/jdalrymple/gitbeaker).

## Installation

You can install this library using npm:

```shell
npm install gitbeaker-hooks
```

## Usage

Wrap your app with the `GitbeakerProvider` and provide options object with `token` property.

```tsx
import { GitbeakerProvider } from "gitbeaker-hooks";

const gitbeakerOptions = {
  token: "your-access-token",
};

ReactDOM.render(
  <React.StrictMode>
    <GitbeakerProvider options={gitbeakerOptions}>
      <App />
    </GitbeakerProvider>
  </React.StrictMode>,
  document.getElementById("root"),
);
```

Use the provided hooks to fetch GitLab data:

- useProjects
- useRepositoryTrees
- useBranches

```tsx
import { useProjects } from "gitbeaker-hooks";

function App() {
  const { projects, isLoading } = useProjects();

  if (isLoading) {
    return <div>Loading...</div>;
  }
  return (
    <>
      <ul>
        {projects?.map((project) => <li key={project.id}>{project.name}</li>)}
      </ul>
    </>
  );
}

export default App;
```

## API

### Hooks

- `useProjects(options)` - Fetch multiple projects.

- `useRepositoryTrees(projectId, options)` - Get a list of repository files and directories in a project.

- `useBranches(projectId, options)` - Get a list of repository branches from a project, sorted by name alphabetically.

### GitbeakerProvider

The `GitbeakerProvider` component should be used to wrap your app and provide the `options` object. The `options` object must include the `token` property.

## Link

- [Gitbeaker](https://github.com/jdalrymple/gitbeaker)
- [@gitbeaker/rest](https://www.npmjs.com/package/@gitbeaker/rest)
- [Docs for GitLab REST API](https://archives.docs.gitlab.com/16.4/ee/api/rest/)

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---
_Source: https://npm.io/package/gitbeaker-hooks · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
