Understanding the architecture
TryDevUtils uses a modular architecture for utilities:- Utility components - Individual tools in
src/components/utils/ - Utility registry - Central registration in
src/lib/utils.ts - Lazy loading - Performance optimization in
src/lib/lazyUtils.ts - Categories - Tools organized by type (Encoding & Decoding, Formatting & Validation, etc.)
Creating a new utility
Create the component file
Create a new file in Use PascalCase for the filename (e.g.,
src/components/utils/ with a descriptive name:Base64Converter.tsx, HashGenerator.tsx).Define the component interface
Your utility component should accept these props:These props enable deep linking and cross-utility navigation.
Build the component
Structure your component with these recommended elements:Key components to use:
Card,CardHeader,CardTitle,CardContent- Layout structureTextarea- Multi-line text inputInput- Single-line input fieldsButton- Action buttonsTabs- Multiple modes/viewsCopyButton- Copy-to-clipboard functionalityuseToast- User notificationsuseUtilKeyboardShortcuts- Standard keyboard shortcuts
Add lazy loading export
Add your utility to Use a short, descriptive ID in lowercase (e.g.,
src/lib/lazyUtils.ts:base64, hash, jwt).Register in the utilities array
Add your utility to the Available categories:
utils array in src/lib/utils.ts:"Encoding & Decoding"- Format conversions, encoding/decoding"Formatting & Validation"- Code formatters, validators"Generators"- Generate UUIDs, hashes, keys, etc."Text & Diff"- Text analysis and comparison"Security & Crypto"- Security-related tools"Reference"- Lookup tables and references
- Choose a unique color gradient not used by similar utilities
- Use Tailwind color classes (e.g.,
from-rose-500 to-rose-600) - Maintain consistency across
color,textColor, andbgColor
Choose an icon
Select an appropriate icon from Lucide React:Icon selection tips:
- Choose icons that clearly represent the tool’s purpose
- Avoid icons already used by similar utilities
- Common choices:
Hash,Key,Braces,FileCode,Link, etc.
Test your utility
Test your new utility thoroughly:Testing checklist:
- Utility appears in the correct category
- Icon and colors display correctly
- Input/output functionality works
- Error handling works properly
- Keyboard shortcuts work (Cmd/Ctrl+Enter, Cmd/Ctrl+K, Cmd/Ctrl+C)
- Toast notifications appear
- Responsive design works on mobile
Best practices
Component structure
- Use functional components with hooks
- Implement
useCallbackfor event handlers to prevent unnecessary re-renders - Use
useStatefor local component state - Handle errors gracefully with try-catch blocks
- Provide clear error messages to users
User experience
- Input validation - Validate user input and show helpful error messages
- Loading states - Show loading indicators for async operations
- Empty states - Provide guidance when there’s no input or output
- Examples - Include example inputs to help users get started
- Keyboard shortcuts - Implement standard shortcuts using
useUtilKeyboardShortcutsCmd/Ctrl+Enter- Execute/processCmd/Ctrl+K- Clear allCmd/Ctrl+C- Copy output
- Copy buttons - Use
CopyButtoncomponent for easy copying - Toast notifications - Confirm actions with toast messages
Performance
- Lazy loading - Always register lazy imports in
lazyUtils.ts - Debouncing - Debounce expensive operations (see
HashGeneratorexample) - Dynamic imports - Load heavy libraries dynamically when needed
- Memoization - Use
useMemofor expensive calculations
Accessibility
- Use semantic HTML elements
- Include proper labels for inputs
- Maintain sufficient color contrast
- Support keyboard navigation
- Provide descriptive button text
Example: studying existing utilities
Look at these utilities as examples:- Simple conversion -
Base64Converter.tsx- Basic encode/decode pattern - Async operations -
HashGenerator.tsx- Dynamic imports and loading states - Multiple tabs -
JsonFormatter.tsx- Complex multi-tab interface - Reference tool -
HttpStatusCodeReference.tsx- Lookup table pattern
Common patterns
Tabs for multiple modes
Copy button with output
Dynamic library imports
Next steps
After creating your utility:- Test it thoroughly across different browsers
- Add examples to help users understand how to use it
- Consider cross-linking with related utilities
- Submit a pull request with a clear description
- Respond to code review feedback
Code style guidelines
Ensure your code follows our style guidelines and conventions