React Hooks library for Backlog.
You can install this library using npm:
npm install use-backlog
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;
-
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.
The BacklogProvider
component should be used to wrap your app.
This project is licensed under the MIT License - see the LICENSE file for details.