Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

gitbeaker-hooks

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbeaker-hooks

React Hooks library for Gitbeaker.

latest
Source
npmnpm
Version
0.2.1
Version published
Weekly downloads
8
Maintainers
1
Weekly downloads
 
Created
Source

gitbeaker-hooks

npm version build codecov License

ko-fi

Overview

React Hooks library for Gitbeaker.

Installation

You can install this library using npm:

npm install gitbeaker-hooks

Usage

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

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
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.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

react

FAQs

Package last updated on 06 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts