{"id":25132979,"url":"https://github.com/vikramsamak/react-api-utils","last_synced_at":"2026-02-04T08:34:30.168Z","repository":{"id":270221979,"uuid":"907941581","full_name":"vikramsamak/react-api-utils","owner":"vikramsamak","description":"A React utility library for making API calls using React Query and Axios, providing context-based configuration and custom hooks for seamless integration.","archived":false,"fork":false,"pushed_at":"2025-01-02T04:02:54.000Z","size":232,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T18:08:03.573Z","etag":null,"topics":["api-calls","api-helper","async-storage","axios","context-provider","data-fetching","http-client","react","react-library","react-query","state-management","typescript"],"latest_commit_sha":null,"homepage":"https://react-api-utils-storybook.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vikramsamak.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-24T16:54:27.000Z","updated_at":"2025-01-08T14:20:39.000Z","dependencies_parsed_at":"2024-12-29T15:30:02.215Z","dependency_job_id":null,"html_url":"https://github.com/vikramsamak/react-api-utils","commit_stats":null,"previous_names":["vikramsamak/react-api-utils","vikramsamak/react-api-helper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikramsamak%2Freact-api-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikramsamak%2Freact-api-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikramsamak%2Freact-api-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vikramsamak%2Freact-api-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vikramsamak","download_url":"https://codeload.github.com/vikramsamak/react-api-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522935,"owners_count":21444632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-calls","api-helper","async-storage","axios","context-provider","data-fetching","http-client","react","react-library","react-query","state-management","typescript"],"created_at":"2025-02-08T15:19:29.098Z","updated_at":"2026-02-04T08:34:25.128Z","avatar_url":"https://github.com/vikramsamak.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# React API Utils\n\nA utility library for simplifying API requests in React applications. Built on top of **React Query** and **Axios**, it provides a seamless way to manage API calls and caching with an intuitive context-based setup.\n\n## Features\n\n- 🌐 **Axios Integration**: Customize API calls with ease.\n- ⚡ **React Query**: Automatic caching, refetching, and stale data management.\n- 📦 **Async Storage Support**: Persisted caching for React Native or browser-based environments.\n- 🛠️ **TypeScript Ready**: Fully typed for better developer experience.\n\n## Installation\n\n```bash\nnpm install react-api-utils\n# or\nyarn add react-api-utils\n```\n\n## Usage\n\n### Setup Provider\n\nWrap your application with the `ApiHelperProvider` to set up the context and configuration.\n\n```tsx\nimport React from 'react';\nimport { ApiHelperProvider } from 'react-api-utils';\n\nconst App = () =\u003e (\n  \u003cApiHelperProvider baseURL=\"https://api.example.com\"\u003e\n    \u003cYourApp /\u003e\n  \u003c/ApiHelperProvider\u003e\n);\n\nexport default App;\n```\n\n### Using `useApiHelper`\n\nLeverage the `useApiHelper` hook to perform API requests effortlessly.\n\n```tsx\nimport { useApiHelper } from 'react-api-utils';\n\nconst MyComponent = () =\u003e {\n  const { data, isLoading, isError } = useApiHelper({\n    url: '/endpoint',\n    method: 'GET',\n    queryKey: ['endpoint-data'],\n  });\n\n  if (isLoading) return \u003cp\u003eLoading...\u003c/p\u003e;\n  if (isError) return \u003cp\u003eSomething went wrong!\u003c/p\u003e;\n\n  return \u003cpre\u003e{JSON.stringify(data, null, 2)}\u003c/pre\u003e;\n};\n```\n\n## API\n\n### `ApiHelperProvider`\n\n| Prop                | Type                 | Default     | Description                       |\n| ------------------- | -------------------- | ----------- | --------------------------------- |\n| `baseURL`           | `string`             | `undefined` | Base URL for all Axios requests.  |\n| `axiosConfig`       | `AxiosRequestConfig` | `{}`        | Custom Axios configuration.       |\n| `queryClientConfig` | `QueryClientConfig`  | `{}`        | React Query client configuration. |\n\n### `useApiHelper`\n\n| Option     | Type                                | Description                                    |\n| ---------- | ----------------------------------- | ---------------------------------------------- |\n| `url`      | `string`                            | API endpoint to fetch data from.               |\n| `method`   | `'GET' , 'POST' , 'PUT' , 'DELETE'` | HTTP method for the request.                   |\n| `queryKey` | `Array\u003cstring\u003e`                     | Unique key for React Query's cache management. |\n\n## Contributing\n\nContributions are welcome! Feel free to submit issues or pull requests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikramsamak%2Freact-api-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvikramsamak%2Freact-api-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvikramsamak%2Freact-api-utils/lists"}