Skip to main content

Overview

Follow these best practices to create high-quality, performant, and maintainable Shopify extensions with Synapse.

Performance Optimization

Bundle Size

Keep extensions under 50KB
  • Remove unused imports
  • Avoid large dependencies
  • Use tree-shaking
  • Code splitting

Load Time

Load in under 500ms
  • Lazy load components
  • Minimize initial render
  • Cache API responses
  • Optimize images

Re-renders

Minimize unnecessary renders
  • Use React.memo
  • Optimize useEffect deps
  • Memoize calculations
  • Avoid inline functions

Function Speed

Functions under 5ms
  • Use Rust over JavaScript
  • Minimize loops
  • Cache results
  • Limit query surface

Code Quality

TypeScript Best Practices

Use strict TypeScript configuration:
Benefits:
  • Catch errors early
  • Better IDE support
  • Self-documenting code
  • Easier refactoring

Component Structure

1

Single Responsibility

Each component does one thing:
2

Extract Custom Hooks

Reuse logic with custom hooks:
3

Memoize Expensive Operations

Use useMemo for calculations:

Function Optimization

Rust vs JavaScript

Use Rust for:
  • Production functions
  • Performance-critical logic
  • Complex calculations
  • Large-scale operations
Benefits:
  • 10-100x faster than JS
  • Compiled to WebAssembly
  • Type safety
  • No garbage collection
Example:

Error Handling

Handle failures without breaking:
Catch component errors:
Never panic in functions:
Explain errors clearly:

Testing

Test individual functions:

Accessibility

Keyboard Navigation

Support keyboard users:

Screen Readers

Label everything:

Color Contrast

Ensure readability:
  • Use Shopify UI components (compliant by default)
  • Avoid custom colors
  • Test with contrast checker
  • Minimum 4.5:1 ratio

Focus States

Visible focus indicators:
  • Shopify components have focus states
  • Don’t remove with CSS
  • Test with Tab key
  • Ensure focus order logical

Security

Validate all user inputs:
Secure API calls:
Never log or expose:

Deployment Best Practices

1

Test Locally First

2

Review MCP Validation

Check validation output before deploying
  • All APIs valid
  • No deprecated components
  • TypeScript compiles
  • No console errors
3

Monitor Deployment

Watch logs during deployment:
Verify deployment succeeds
4

Test in Dev Store

  • Add items to cart
  • Go through checkout
  • Test all code paths
  • Verify on mobile
5

Monitor Performance

  • Check loading times
  • Review error rates
  • Monitor function execution time
  • Track user feedback

Documentation

Write clear documentation:

Next Steps

Debugging

Learn debugging techniques

Troubleshooting

Common issues and solutions

Extension Standards

Quality guidelines

Validation

MCP validation process