This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is react-loqate, a React component library for Loqate address search API integration. The main component is AddressSearch which provides an input field with dropdown suggestions that integrates with Loqate's address lookup services.
pnpm build- Build the library using tsup (ESM, CJS formats with TypeScript declarations)pnpm dev- Start Storybook development server on port 6006pnpm check- Run linting and type checking (used by pre-commit hook)
pnpm test- Run tests with Vitest in watch modepnpm test:ci- Run tests once for CIpnpm lint- Run ESLint and Prettier checkstsc- Run TypeScript compiler for type checking
pnpm changeset- Create a changeset for version managementpnpm publish:ci- Build and publish to npm (CI only)
- Main Component:
src/index.tsxcontains theAddressSearchcomponent - Default Components: Located in
src/components/-DefaultInput,DefaultList,DefaultListItem - API Layer:
src/utils/Loqate.tshandles all API communication with Loqate services - Custom Hooks:
src/utils/useDebounceEffect.tsfor debouncing user input
- Component Composition: Supports custom components via
componentsprop (Input, List, ListItem) - Portal Rendering: Uses MUI Base Portal for dropdown positioning (can be disabled with
inlineprop) - Error Handling: Two error types -
LoqateError(API errors) andReactLoqateError(client errors) - Debouncing: Built-in debounced API calls (default/configurable timeout)
The component integrates with two Loqate API endpoints:
- Find API: Search for address suggestions based on text input
- Retrieve API: Get full address details when user selects a suggestion
- Core: React 18+, MUI Base (for Portal/ClickAwayListener), clsx for class management
- Build: tsup for bundling, TypeScript for types
- Testing: Vitest with jsdom, React Testing Library
- Development: Storybook for component development, ESLint + Prettier for code quality
Tests use Vitest with React Testing Library and jsdom environment. Test files are located in:
src/index.test.tsx- Main component testssrc/utils/__tests__/- Utility function tests
Coverage is configured to include all TypeScript files in the src/ directory.
- TypeScript: Strict mode enabled with comprehensive type checking
- ESLint: Uses recommended rules + TypeScript + Storybook plugins
- Prettier: Configured for 80-character lines, semicolons, single quotes
- Husky: Pre-commit hook runs
pnpm check - Package Manager: Uses pnpm with lockfile
Uses Changesets for version management:
- Create feature branch with changes
- Add changeset with
pnpm changeset - Create PR to main
- GitHub Actions creates/updates release PR
- Merge release PR triggers automated publishing