Quick Start
Use the package generator to create a new package:Example
/suite-common/wallet folder.
Understanding Package Scopes
Choose the correct scope based on what your package does and what it needs to import:@trezor/*
Location:
/packagesUse for: Public packages used by Suite and third partiesCan import: Nothing from other scopesExamples: @trezor/connect, @trezor/utils@suite-common
Location:
/suite-commonUse for: Code shared between web/desktop and mobile SuiteCan import: @trezor/* onlyExamples: Wallet logic, shared state management@suite-native
Location:
/suite-nativeUse for: Mobile Suite (React Native)Can import: @trezor/*, @suite-commonExamples: Mobile-specific UI, native integrations@suite
Location:
/suiteUse for: Desktop and web SuiteCan import: @trezor/*, @suite-commonExamples: Web-specific features, desktop integrationsUsing Your New Package
After creating a package, follow these steps to use it:Add to Dependencies
Add the package to the
dependencies field in package.json of the consuming package:package.json
Package Design Best Practices
Smaller is Better
Creating smaller packages helps avoid cyclic dependencies and improves maintainability.Benefits of Smaller Packages
Avoid Cyclic Dependencies
Smaller packages reduce the chance of circular import issues.
Better Control
Fine-grained control over what other packages can use.
Faster Testing
Run smaller subsets of tests and lints for faster feedback.
Clear Purpose
Each package has a well-defined, focused responsibility.
Package Structure
A typical package structure looks like:Package Configuration
package.json
Key fields in yourpackage.json:
package.json
TypeScript Configuration
Yourtsconfig.json should extend the root configuration:
tsconfig.json
Preventing Cyclic Dependencies
The Problem
Cyclic dependencies occur when:The Solution
Extract shared code into a separate package:Respect Scope Boundaries
Testing Your Package
After creating a package, ensure it works correctly:Common Pitfalls
Examples
Creating a Utility Package
Creating a Shared State Package
Creating a Platform-Specific Package
Next Steps
Package Overview
Browse all packages in the monorepo
Common Tasks
Learn about dependency management and troubleshooting
TypeScript Guide
TypeScript conventions and best practices
Testing
How to write tests for your package