A React + TypeScript app for scoring a cribbage hand, the crib, and the starter card from a single screen.
The app lets you:
- Enter a 4-card player hand
- Enter a 4-card crib
- Choose a starter card
- Score the hand and crib separately
- See a scoring breakdown for fifteens, pairs, runs, flushes, and nobs
- Catch duplicate card selections before trusting the result
The player hand uses normal cribbage hand rules, and the crib uses crib-specific flush rules.
- React 19
- TypeScript
- Vite
Install dependencies:
npm installRun the development server:
npm run devVite will print a local URL, typically http://localhost:5173.
Build the app:
npm run buildPreview the production build locally:
npm run preview- Select the four cards in the player hand section.
- Select the four cards in the crib section if you want to score the crib too.
- Choose the starter card.
- Review the score panels for the hand and crib totals.
- Check the scoring breakdown to see exactly where each point came from.
If the app reports duplicate cards, update the selections until each physical card appears only once.
Use the Clear all cards button to reset the board and start a new score.
The scoring engine currently handles:
- Fifteens
- Pairs
- Runs
- Flushes
- Nobs
Important files:
src/components/HomePage/HomePage.tsxmanages app state and score calculationsrc/components/PlayerHand/PlayerHand.tsxrenders player hand inputssrc/components/Crib/Crib.tsxrenders crib inputssrc/components/DrawCard/DrawCard.tsxrenders starter card inputssrc/components/ScoreResult/ScoreResult.tsxrenders totals and scoring detailssrc/utils/scoringLogic.tscontains the cribbage scoring rules
- Add automated tests for known cribbage hands
- Add faster card selection with visual card buttons
- Add example hands for quick QA
- Add pegging score helpers