{"id":25491788,"url":"https://github.com/gregory-dushan/headlesscms-react-integration","last_synced_at":"2026-04-05T23:32:53.223Z","repository":{"id":276861959,"uuid":"930548144","full_name":"gregory-dushan/headlesscms-react-integration","owner":"gregory-dushan","description":"This repository demonstrates how to integrate a Contentstack Headless CMS with a React frontend to deliver dynamic, API-driven content.","archived":false,"fork":false,"pushed_at":"2025-02-10T20:25:52.000Z","size":162,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-03T18:50:35.236Z","etag":null,"topics":["apiintegration","contentstack","context-api","headlesscms","hooks","nextjs","react","redux"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gregory-dushan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-02-10T20:11:46.000Z","updated_at":"2025-02-10T20:25:55.000Z","dependencies_parsed_at":"2025-02-10T21:31:02.742Z","dependency_job_id":"d0132f2f-037f-4bc8-bde1-7e5b71d1fb32","html_url":"https://github.com/gregory-dushan/headlesscms-react-integration","commit_stats":null,"previous_names":["gregory-dushan/headlesscms-react-integration"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gregory-dushan/headlesscms-react-integration","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-dushan%2Fheadlesscms-react-integration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-dushan%2Fheadlesscms-react-integration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-dushan%2Fheadlesscms-react-integration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-dushan%2Fheadlesscms-react-integration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gregory-dushan","download_url":"https://codeload.github.com/gregory-dushan/headlesscms-react-integration/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gregory-dushan%2Fheadlesscms-react-integration/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31454197,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-05T21:22:52.476Z","status":"ssl_error","status_checked_at":"2026-04-05T21:22:51.943Z","response_time":75,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: 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":["apiintegration","contentstack","context-api","headlesscms","hooks","nextjs","react","redux"],"created_at":"2025-02-18T22:18:47.991Z","updated_at":"2026-04-05T23:32:53.203Z","avatar_url":"https://github.com/gregory-dushan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Headless CMS React Integration 🚀  \n\nThis project demonstrates how to integrate a **Headless CMS** (e.g., Contentstack, Strapi, Sanity, or Contentful) with a **React** frontend to deliver dynamic, API-driven content.  \n\n## 🔹 Features  \n✅ Fetch and render content dynamically from a Headless CMS  \n✅ Optimized API calls with caching \u0026 lazy loading  \n✅ Custom React hooks for content retrieval  \n✅ SEO-friendly rendering \u0026 metadata management  \n✅ Modular and scalable architecture  \n\n---\n\n## 📦 Installation  \n\n1. Clone the repository:  \n   ```sh\n   git clone https://github.com/gregory-dushan/headlesscms-react-integration.git\n   cd headlesscms-react-integration\n   ```\n\n2. Install dependencies:  \n   ```sh\n   npm install\n   # or\n   yarn install\n   ```\n\n3. Set up environment variables:  \n   Create a `.env` file in the root directory and add your CMS API keys:  \n   ```env\n   REACT_APP_CMS_API_URL=your_cms_api_url\n   REACT_APP_CMS_ACCESS_TOKEN=your_cms_access_token\n   ```\n\n---\n\n## 🚀 Running the Project  \n\n### Development Mode  \n```sh\nnpm run dev\n# or\nyarn dev\n```\nThe app will be available at `http://localhost:3000`.\n\n### Production Build  \n```sh\nnpm run build\n# or\nyarn build\n```\nThis generates a static build in the `build/` directory.\n\n---\n\n## 🛠 Project Structure  \n```\n📂 src/\n ┣ 📂 components/        # Reusable UI components\n ┣ 📂 hooks/             # Custom React hooks for fetching CMS data\n ┣ 📂 pages/             # Page components\n ┣ 📂 libs/              # API service functions\n ┣ 📂 types/             # Type definition\n ┣ 📜 App.js             # Main React component\n ┗ 📜 index.js           # React DOM entry point\n```\n\n---\n\n## 🔗 API Integration  \n\nTo fetch data from your Headless CMS, this project uses **custom React hooks**.  \n\nExample: Fetching CMS content inside a component:  \n```jsx\nimport { useEffect, useState } from \"react\";\n\nconst useFetchCMSData = (endpoint) =\u003e {\n  const [data, setData] = useState(null);\n  const [loading, setLoading] = useState(true);\n\n  useEffect(() =\u003e {\n    fetch(`${process.env.REACT_APP_CMS_API_URL}/${endpoint}`, {\n      headers: {\n        Authorization: `Bearer ${process.env.REACT_APP_CMS_ACCESS_TOKEN}`,\n      },\n    })\n      .then((res) =\u003e res.json())\n      .then((data) =\u003e {\n        setData(data);\n        setLoading(false);\n      })\n      .catch((error) =\u003e console.error(\"Error fetching CMS data:\", error));\n  }, [endpoint]);\n\n  return { data, loading };\n};\n\nexport default useFetchCMSData;\n```\n\n---\n\n## 📝 Roadmap  \n- [ ] Add GraphQL support for Contentful  \n- [ ] Implement SSR support with Next.js  \n- [ ] Improve caching strategy  \n\n---\n\n## 🤝 Contributing  \n1. Fork the repo  \n2. Create a new branch (`git checkout -b feature-branch`)  \n3. Commit your changes (`git commit -m \"Add new feature\"`)  \n4. Push to your branch (`git push origin feature-branch`)  \n5. Open a **Pull Request**  \n\n---\n\n## 📜 License  \nThis project is licensed under the **MIT License**.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregory-dushan%2Fheadlesscms-react-integration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgregory-dushan%2Fheadlesscms-react-integration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgregory-dushan%2Fheadlesscms-react-integration/lists"}