Skip to content

ryohidaka/use-backlog

Repository files navigation

use-backlog

npm version build codecov License

ko-fi

Overview

React Hooks library for Backlog.

Installation

You can install this library using npm:

npm install use-backlog

Usage

Wrap your app with the BacklogProvider and provide host and apiKey property.

import { BacklogProvider } from "use-backlog";

ReactDOM.render(
  <React.StrictMode>
    <BacklogProvider>
      <App />
    </BacklogProvider>
  </React.StrictMode>,
  document.getElementById("root"),
);

Use the provided hooks to fetch Backlog data:

  • useProjects
  • useProject
  • useIssues
  • useIssue
  • useMyself
import { useBacklog, useProjects } from "use-backlog";

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

  setConfig?.({ host: "example.com", apiKey: "hogehoge" });

  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(params, swrConfig) - Fetch multiple projects.

  • useProject(projectIdOrKey, swrConfig) - Get a project.

  • useIssues(params, swrConfig) - Get a list of issues in a project.

  • useIssue(issueIdOrKey, swrConfig) - Get a issue.

  • useMyself(swrConfig) - Get own information about user.

BacklogProvider

The BacklogProvider component should be used to wrap your app.

Link

License

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