Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ryohidaka/gitbeaker-hooks
React Hooks library for Gitbeaker.
https://github.com/ryohidaka/gitbeaker-hooks
git gitbeaker gitlab react react-hooks
Last synced: about 1 month ago
JSON representation
React Hooks library for Gitbeaker.
- Host: GitHub
- URL: https://github.com/ryohidaka/gitbeaker-hooks
- Owner: ryohidaka
- License: mit
- Created: 2024-03-31T22:53:51.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-09-02T04:46:40.000Z (4 months ago)
- Last Synced: 2024-10-08T10:55:55.676Z (3 months ago)
- Topics: git, gitbeaker, gitlab, react, react-hooks
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/gitbeaker-hooks
- Size: 464 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
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(
,
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) {
returnLoading...;
}
return (
<>
- {project.name} )}
{projects?.map((project) =>
>
);
}
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.