Skip to content

πŸš€ A modern, type-safe review platform built with React, TypeScript, and Strapi 5. Features Apollo Client integration, GraphQL data fetching, and Strapi’s new Document Service.

Notifications You must be signed in to change notification settings

goldipl/react-strapi-graphql-site

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

React Strapi 5 GraphQL Reviews

A modern, type-safe review site built with React and TypeScript. This project fetches content from Strapi 5 using GraphQL for optimized data delivery.

πŸ“‚ Project Structure

react-strapi-graphql-site/
β”œβ”€β”€ backend/                    # Strapi 5 headless CMS
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ admin.ts           # Admin panel configuration
β”‚   β”‚   β”œβ”€β”€ api.ts             # API configuration
β”‚   β”‚   β”œβ”€β”€ database.ts        # Database connection settings
β”‚   β”‚   β”œβ”€β”€ middlewares.ts      # Middleware configuration
β”‚   β”‚   β”œβ”€β”€ plugins.ts         # Plugin configuration
β”‚   β”‚   └── server.ts          # Server configuration
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ api/
β”‚   β”‚   β”‚   └── review/        # Review content type
β”‚   β”‚   β”‚       β”œβ”€β”€ content-types/
β”‚   β”‚   β”‚       β”‚   └── review/schema.json
β”‚   β”‚   β”‚       β”œβ”€β”€ controllers/review.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ routes/review.ts
β”‚   β”‚   β”‚       └── services/review.ts
β”‚   β”‚   β”œβ”€β”€ admin/             # Admin panel customization
β”‚   β”‚   β”œβ”€β”€ extensions/        # Strapi extensions
β”‚   β”‚   └── index.ts           # Entry point
β”‚   β”œβ”€β”€ types/
β”‚   β”‚   └── generated/         # Auto-generated TypeScript types
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ robots.txt
β”‚   β”‚   └── uploads/           # Media uploads
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   └── migrations/        # Database migrations
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   └── .env                   # Environment variables
β”‚
β”œβ”€β”€ frontend/                   # React + TypeScript frontend
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   β”œβ”€β”€ manifest.json
β”‚   β”‚   └── robots.txt
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ graphql/
β”‚   β”‚   β”‚   └── queries.ts     # Centralized GraphQL query definitions
β”‚   β”‚   β”œβ”€β”€ types/
β”‚   β”‚   β”‚   └── review.ts      # TypeScript interfaces for Review data
β”‚   β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”‚   β”œβ”€β”€ Homepage.tsx   # Review listing with content snippets
β”‚   β”‚   β”‚   └── ReviewDetails.tsx # Full review view by documentId
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   └── SiteHeader.tsx # Reusable header component
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   └── useFetch.ts    # Utility for standard REST fetching
β”‚   β”‚   β”œβ”€β”€ App.tsx            # Root component
β”‚   β”‚   β”œβ”€β”€ index.tsx          # Apollo Client and Provider configuration
β”‚   β”‚   β”œβ”€β”€ index.css          # Global styles
β”‚   β”‚   └── setupTests.ts      # Test configuration
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tsconfig.json
β”‚   β”œβ”€β”€ tailwind.config.js     # Tailwind CSS configuration
β”‚   β”œβ”€β”€ postcss.config.js      # PostCSS configuration
β”‚   └── .env                   # Environment variables
β”‚
└── README.md

πŸš€ Features

  • Strapi 5 Document Service: Uses documentId for stable, SEO-friendly routing.
  • Apollo Client Integration: Efficient data fetching with built-in caching.
  • Type-Safe Schema: Full TypeScript support for Strapi's "Blocks" (JSON) content.
  • GraphQL API: Requests only the fields required, reducing payload size.

πŸ› οΈ Tech Stack

  • Frontend: React, TypeScript, React Router 6, Tailwind CSS
  • API Client: Apollo Client (GraphQL)
  • Backend: Strapi 5
  • Content: Strapi Blocks (Rich Text)

πŸ“¦ Getting Started

1. Backend Setup (Strapi)

  1. Ensure you have the GraphQL plugin installed in your Strapi directory:
npm install @strapi/plugin-graphql
  1. Run the develop server:
npm run develop
  1. Permissions: In the Strapi Admin, go to Settings > Roles > Public. Enable find and findOne for the Review collection.

2. Frontend Setup (React)

  1. Install dependencies:
npm install
  1. Start the development server:
npm start

πŸ“‘ GraphQL Schema Summary

The project interacts with the following Review schema:

Field Type Description
documentId ID! The unique identifier for the document.
title String! Review title.
rating Int! Numeric score.
body JSON! Strapi Blocks rich text data.

πŸ“‘ Example Query

Data is fetched using the following query structure in src/graphql/queries.ts:

query GetReviews {
  reviews {
    documentId
    title
    rating
    body
  }
}

πŸ”§ Scripts

  • npm start: Runs the app in development mode.
  • npm run build: Optimizes the app for production.
  • npm test: Launches the test runner.

πŸ–ΌοΈ Screenshots

screenshot screenshot

πŸ“„ License

Distributed under the MIT License.

About

πŸš€ A modern, type-safe review platform built with React, TypeScript, and Strapi 5. Features Apollo Client integration, GraphQL data fetching, and Strapi’s new Document Service.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published