{"id":17473731,"url":"https://github.com/parv3213/collabland-tokengate-react-context","last_synced_at":"2026-04-28T20:32:15.875Z","repository":{"id":177549193,"uuid":"660539262","full_name":"parv3213/collabland-tokengate-react-context","owner":"parv3213","description":"React Context Provider for Collab.Land's TokenGate APIs","archived":false,"fork":false,"pushed_at":"2023-07-19T16:14:21.000Z","size":1149,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-24T01:45:04.668Z","etag":null,"topics":["collabland","react","tokengate","typescript"],"latest_commit_sha":null,"homepage":"https://collabland-tokengate-react-context.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/parv3213.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":"2023-06-30T08:30:25.000Z","updated_at":"2023-07-13T17:50:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"29e66504-bfc7-452f-9fbf-b752b9e07920","html_url":"https://github.com/parv3213/collabland-tokengate-react-context","commit_stats":{"total_commits":37,"total_committers":4,"mean_commits":9.25,"dds":"0.21621621621621623","last_synced_commit":"e80b407e5ee7d5acb2e953e25bd7f50a8e7ebe73"},"previous_names":["parv3213/collablank-tokengate-react-context"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/parv3213/collabland-tokengate-react-context","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parv3213%2Fcollabland-tokengate-react-context","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parv3213%2Fcollabland-tokengate-react-context/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parv3213%2Fcollabland-tokengate-react-context/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parv3213%2Fcollabland-tokengate-react-context/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/parv3213","download_url":"https://codeload.github.com/parv3213/collabland-tokengate-react-context/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/parv3213%2Fcollabland-tokengate-react-context/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32398504,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T19:38:08.556Z","status":"ssl_error","status_checked_at":"2026-04-28T19:37:55.688Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["collabland","react","tokengate","typescript"],"created_at":"2024-10-18T18:06:47.689Z","updated_at":"2026-04-28T20:32:15.856Z","avatar_url":"https://github.com/parv3213.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# collabland-tokengate-react-context\n\n## React Context Provider for Collab.Land's TokenGate APIs\n\n[![NPM version][npm-image]][npm-url]\n[![Build][github-build]][github-build-url]\n![npm-typescript]\n[![License][github-license]][github-license-url]\n\nToken Gate React Context is a package that provides a React context for token gating users based on specific rules. It utilizes the Collab Land APIs to implement this functionality.\n\n\n[**Live Demo**](https://collabland-tokengate-react-context.vercel.app/)\n\n## Installation:\nYou can install the package using npm:\n```bash\nnpm install collabland-tokengate-react-context\n```\n\nor\n\n```bash\nyarn add -D collabland-tokengate-react-context\n```\n\n## Usage :\n\nTo use the Token Gate React Context, follow these steps:\n1. Import the `TokenGateProvider` component from the package and wrap your React application or a specific component with the `TokenGateProvider` component-\n\n\n```tsx\nimport { TokenGateProvider } from 'collabland-tokengate-react-context'\n\nfunction App() {\n  return (\n    \u003cTokenGateProvider\u003e\n      {/* Your app components */}\n    \u003c/TokenGateProvider\u003e\n  );\n}\n)\n\n```\n\n2. Access the token gate state and methods within your components using the `TokenGateContext`-\n```tsx\nimport { useContext } from \"react\";\nimport { TokenGateContext } from \"collabland-tokengate-react-context\";\n\nfunction MyComponent() {\n  const { checkRoles, result, isLoading, error } = useContext(TokenGateContext);\n\n  // Use the checkRoles function, result, isLoading, and error as needed\n\n  return (\n    // Your component JSX\n  );\n}\n```\n\n\n## TokenGateProvider\nThe `TokenGateProvider` component is a context provider that encapsulates the logic for making API requests to the Collab Land API and manages the state related to token gating.\n\n\n\n#### Props\n- `children` (React.ReactNode): The components to be wrapped within the provider.\n\n#### Context Value\nThe context value, `TokenGateContext`, provided by the `TokenGateProvider` component has the following properties:\n\n- `checkRoles`: A function that accepts a `CheckRoleRequest` object and the Collab Land API key as parameters, and returns a promise. This function is used to make API requests to check the roles.\n- `result`: An object that contains the result of the API request (called within `checkRoles`), i.e. an array of roles. Each role object in the array has the following properties:\n    - `roleId`: A string representing the ID of the role.\n    - `granted`: A boolean indicating whether the role is granted.\n- `isLoading`: A boolean flag indicating whether the API request is in progress.\n- `error`: An error object containing information about any errors that occurred.\n\nNote: The `TokenGateProvider` component should be placed higher up in the component tree to ensure that the context is available to all components that need it.\n\n\n[npm-url]: https://www.npmjs.com/package/collabland-tokengate-react-context\n[npm-image]: https://img.shields.io/npm/v/collabland-tokengate-react-context\n[github-license]: https://img.shields.io/github/license/parv3213/collabland-tokengate-react-context\n[github-license-url]: https://github.com/parv3213/collabland-tokengate-react-context/blob/main/LICENSE\n[github-build]: https://github.com/parv3213/collabland-tokengate-react-context/actions/workflows/publish.yml/badge.svg\n[github-build-url]: https://github.com/parv3213/collabland-tokengate-react-context/actions/workflows/publish.yml\n[npm-typescript]: https://img.shields.io/npm/types/collabland-tokengate-react-context\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparv3213%2Fcollabland-tokengate-react-context","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fparv3213%2Fcollabland-tokengate-react-context","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fparv3213%2Fcollabland-tokengate-react-context/lists"}