Overview
BodyWorks includes a powerful search feature that lets you quickly find exercises by name. The search bar uses debounced input to provide a smooth, responsive experience while searching through the entire exercise database.Instant search
Real-time results as you type with 500ms debounce
Search by name
Find exercises using their titles and names
Keyword matching
Exercise keywords help expand search results
Responsive UI
Works seamlessly on all device sizes
How search works
Search component
The search bar is a debounced input component that prevents excessive API calls:search-bar.tsx
Key features
Debounced input
Debounced input
Search uses a 500ms debounce delay, meaning:
- The search doesn’t trigger on every keystroke
- Wait 500ms after you stop typing
- Then the search query is sent
- Reduces unnecessary API calls
- Improves performance and responsiveness
Memoized component
Memoized component
The SearchBar is wrapped in
React.memo() to prevent unnecessary re-renders:- Only re-renders when props change
- Maintains search state efficiently
- Optimizes performance in large lists
Responsive design
Responsive design
The search input adapts to screen size:
- Small text on mobile (
xs:text-xs) - Normal text on desktop (
md:text-base) - Centered with max-width constraint
- Transparent background that adapts to theme
Where search is available
Exercises page
The main search implementation is on the exercises page:exercises/page.tsx
URL-based search
Search queries are reflected in the URL:- Shareable search results
- Browser back/forward navigation
- Bookmarking searches
- Deep linking to search results
What can be searched
Exercise fields
The search functionality matches against exercise data:Searchable content
Exercise keywords
Keywords expand search results:
- “chest” → finds chest exercises
- “compound” → finds compound movements
- “beginner” → finds beginner-friendly exercises
- “strength” → finds strength training exercises
Search patterns and tips
Effective searching
- By exercise name
- By movement pattern
- By keyword
- By equipment
Search for specific exercises:
Search tips
Pro tips for better results:
- Use specific terms: “bench” is better than “chest”
- Try different variations: “pullup”, “pull up”, “pull-up”
- Start broad, then narrow: “press” → “shoulder press”
- Check spelling: Ensure correct spelling for best matches
- Use partial words: “should” will find “shoulder” exercises
Combining search with filters
While search is text-based, you can combine it with filter navigation:Example workflow
Start with a filter
Filter by body part, equipment, or target muscle:
- Visit
/equipments/dumbbell - Shows all dumbbell exercises
Refine with search
From there, you could:
- Go to
/exercises - Search for “dumbbell press”
- Get more specific results
Search behavior
Empty results
When no exercises match your search:Loading states
While searching, the page shows:- Loading skeletons during initial load
- Smooth transitions between states
- Responsive feedback for user actions
Clearing search
To clear your search:- Delete text from the search bar
- Wait for debounce (500ms)
- Returns to showing all exercises
- Or navigate directly to
/exercises
Search performance
Optimization techniques
Debouncing
500ms delay prevents excessive API calls while typing
Memoization
React.memo prevents unnecessary component re-renders
URL state
Query parameters enable sharing and navigation
Pagination
Results limited to 9 per page for fast rendering
Best practices
For optimal search experience:- Wait for debounce to complete before typing more
- Use specific search terms when possible
- Combine with filters for better narrowing
- Check exercise keywords if you don’t find what you need
- Try alternative spellings or terms
Technical implementation
Search flow
Integration points
Search integrates with:- URL routing: Search queries in URL parameters
- Exercise hooks:
useExercises()accepts search parameters - Pagination: Works alongside paginated results
- Error handling: Graceful fallbacks for failed searches
Future enhancements
Potential search improvements:- Advanced filters (multiple muscles, equipment)
- Autocomplete suggestions
- Search history
- Saved searches
- Fuzzy matching for typos
- Search by muscle group
- Voice search capability
Explore all features
Return to exercise database overview to learn about all 1300+ exercises