This is a starter template for building a blog with Next.js, Contentful, and Mux. It includes a Docker-based development workflow for a consistent development experience across teams.
- Docker Desktop installed and running
- Git
No other local dependencies are required! Everything runs inside Docker containers.
-
Clone the repository:
git clone <repository-url> cd contentful-mux-nextjs-starter
-
Copy the environment file:
cp .env.example .env.development
-
Update
.env.developmentwith your credentials:CONTENTFUL_SPACE_IDCONTENTFUL_ACCESS_TOKENCONTENTFUL_PREVIEW_ACCESS_TOKENMUX_TOKEN_IDMUX_TOKEN_SECRET
Our Docker setup provides a consistent development environment with:
- 🔥 Hot-reloading for instant feedback
- 📦 Cached node_modules for faster builds
- 🛠️ Built-in debugging support
- 🔍 Health checks for reliability
- 👤 Secure non-root user setup
# Start development server
npm run docker:start
# Build the application
npm run docker:build
# Run linting and type checking
npm run docker:check
# Stop the development server
npm run docker:down
# Clean up containers and volumes
npm run docker:clean
# Remove all Matic Docker resources
npm run docker:purge- Hot Reloading: Changes to your code will automatically trigger rebuilds
- Container Management:
- The container is named
Matic-Docker-Appfor easy identification - Volumes are prefixed with
matic-docker-for organization
- The container is named
- Automatic Cleanup:
- Pressing Ctrl+C during development automatically cleans up resources
docker:checkautomatically manages container lifecycle
- Development Tools:
- Access container shell:
./scripts/dev shell - View logs:
./scripts/dev logs - Check status:
./scripts/dev status
- Access container shell:
-
Development Workflow
- Use
npm run docker:startfor daily development - Run
npm run docker:checkbefore committing changes - Keep the logs visible for debugging
- Use
-
Resource Management
- Use
npm run docker:cleanto clean up after development - Use
npm run docker:purgewhen switching branches or for deep cleaning
- Use
-
Troubleshooting
- Check container status with
./scripts/dev status - View logs with
./scripts/dev logs - If in doubt, run
npm run docker:purgeand start fresh
- Check container status with
If you prefer to develop without Docker, you'll need:
- Node.js (version specified in package.json)
- npm (version specified in package.json)
Then you can use these commands:
# Install dependencies
npm install
# Start development server
npm run dev
# Build the application
npm run build
# Run linting and type checking
npm run checkOur feature development workflow is designed to maintain high code quality and consistency across the team. Follow these guidelines for all feature development:
-
Branch Naming Convention:
<type>/<ticket-number>-<brief-description>- Types:
feature,bugfix,hotfix,refactor,docs - Example:
feature/MATIC-123-add-video-player
- Types:
-
Branch Lifecycle:
- Create from latest
main - Regular commits during development
- Rebase with
mainbefore PR - Delete after merge
- Create from latest
-
Planning:
- Review ticket requirements
- Break down into tasks
- Identify affected components
- Plan test coverage
-
Local Development:
# Start fresh with a new branch git checkout main git pull git checkout -b feature/MATIC-XXX-description # Start development environment npm run docker:start
-
Development Loop:
- Write code with hot-reloading
- Run checks frequently:
npm run docker:check
- Commit logical chunks of work
- Update tests and documentation
-
Commit Messages:
<type>: <description> [optional body] [optional ticket reference]- Types:
feat,fix,refactor,docs,style,test,chore - Example:
feat: add video player component
- Types:
-
Pre-commit Checks:
- Linting (ESLint)
- Type checking (TypeScript)
- Code formatting (Prettier)
- Unit tests (if applicable)
-
Code Style:
- Follow ESLint configuration
- Use TypeScript strictly
- Document complex logic
- Keep components focused
- Follow project structure
-
Preparation:
# Ensure all changes are committed git status # Rebase with main git checkout main git pull git checkout your-branch git rebase main # Verify everything works npm run docker:purge # Clean slate npm run docker:start # Verify app works npm run docker:check # Run all checks
-
PR Creation:
- Use PR template
- Link related tickets
- Add screenshots/videos if UI changes
- Tag relevant reviewers
-
PR Description:
- Summarize changes
- List testing steps
- Note any breaking changes
- Include deployment considerations
-
Review Process:
- Address review comments
- Keep PR updated with main
- Get required approvals
- Ensure all checks pass
- Unit Tests: Required for utilities and hooks
- Integration Tests: Required for complex features
- UI Tests: Required for critical user flows
- Manual Testing:
- Test in development environment
- Cross-browser testing if needed
- Mobile responsiveness if applicable
- Update README if needed
- Add inline documentation
- Update API documentation
- Document breaking changes
- Add usage examples
-
Staging:
- Automatic deployment on PR
- Verify features in staging
- Run smoke tests
-
Production:
- Merge to main
- Monitor deployment
- Verify in production
- Be ready to rollback
If you encounter issues:
-
Docker Issues:
# Clean slate approach npm run docker:purge docker system prune -af # Be careful with this! npm run docker:start
-
Development Issues:
- Check container logs:
./scripts/dev logs - Verify environment variables
- Clear node_modules:
npm run docker:clean
- Check container logs:
-
Build Issues:
- Verify dependencies
- Check TypeScript errors
- Review build logs
- Keep PRs focused and small
- Write descriptive commit messages
- Update tests with code changes
- Document complex logic
- Follow the single responsibility principle
- Use feature flags for big changes
- Keep dependencies updated
- Monitor performance impacts
When creating a pull request, copy and fill out the following template:
# Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context.
Fixes # (issue)
## Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
## How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
- [ ] Test A
- [ ] Test B
## Checklist:
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules
## Screenshots (if applicable):
## Additional context:
Add any other context about the pull request here.
## Deployment Notes:
Describe any deployment steps, configuration changes, or other considerations.contentful-mux-nextjs-starter/
├── docker/ # Docker-related files
│ ├── Dockerfile # Development Dockerfile
│ └── docker-compose.yml # Development compose configuration
├── src/ # Application source code
│ ├── app/ # Next.js app router files
│ ├── components/ # Reusable React components
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility functions and libraries
│ └── styles/ # CSS and styling files
├── .env.development # Development environment variables
├── .env.example # Template for environment variables
├── package.json # Node.js dependencies and scripts
└── README.md # Project documentation
https://github.com/alan2207/bulletproof-react/blob/master/docs/project-standards.md
- ESlint
- file naming conventions
- Prettier
- TypeScript
- Husky
- pre-commit hooks
- absolute imports
- tsconfig.json
https://github.com/alan2207/bulletproof-react/blob/master/docs/project-structure.md
https://github.com/alan2207/bulletproof-react/blob/master/docs/components-and-styling.md
- shadcn/ui for UI components
- Radix Primitives
- TailwindCSS
- components.json for configuration
https://github.com/alan2207/bulletproof-react/blob/master/docs/api-layer.md
- Contentful GraphQL Content Delivery API
- fetchGraphQL function
- custom getters
- custom server side functions
- Tanstack Query
- uses api fucntions custom client hooks
- Mux for video streaming
- the plabackId from the Contentful API
- the muxData from the Mux API
- React Query for data fetching
- React Query DevTools for debugging
https://github.com/alan2207/bulletproof-react/blob/master/docs/state-management.md
- useState for component state
- Jotai for application state management
- Jotai DevTools for debugging
- @tanstack/react-form for form state management
- @tanstack/zod-form-adapter for form validation
https://github.com/alan2207/bulletproof-react/blob/master/docs/error-handling.md
- API Errors for server-side errors
- React Error Boundary for component-level error handling
- ErrorPage for custom error pages
When implementing animations in your components, ask these questions to determine the best approach:
-
Is it a simple state transition?
- If yes → Use Tailwind animations
- Examples: hover states, fade-ins, simple transitions
-
Does it need user interaction?
- Basic interaction → Use Tailwind animations
- Complex interaction (gestures, drag) → Use Framer Motion
- Examples:
- Tailwind: hover effects, click feedback
- Framer: drag and drop, pinch to zoom
-
Does it need to respond to gestures?
- If yes → Use Framer Motion
- Examples: swipe actions, pull to refresh
-
Is it purely decorative?
- If yes → Use Tailwind animations
- Examples: loading states, entrance animations
-
Does it need to coordinate with other elements?
- If yes → Use Framer Motion
- Examples: synchronized animations, staggered lists
See the animation examples in src/app/template/page.tsx for implementation details.
TBD https://github.com/alan2207/bulletproof-react/blob/master/docs/testing.md
https://github.com/alan2207/bulletproof-react/blob/master/docs/security.md TBD
https://github.com/alan2207/bulletproof-react/blob/master/docs/deployment.md
- Create a feature branch
- Make your changes
- Submit a pull request