When updating existing APIs, maintain backward compatibility by deprecating old options rather than introducing breaking changes. Add new properties while keeping old ones functional, marking them as deprecated to guide migration without forcing immediate updates.
Key principles:
Example approach for API updates:
// Instead of breaking change:
// OLD: { blockerFn?: Function }
// NEW: { shouldBlockFn: Function } // ❌ Breaking!
// Use backward-compatible approach:
type UseBlockerOpts = {
shouldBlockFn: BlockerFn // New preferred option
enableBeforeUnload?: boolean
} & {
blockerFn?: LegacyBlockerFn // Keep old option, mark deprecated
condition?: boolean // Keep old option, mark deprecated
}
This approach ensures existing code continues working while encouraging adoption of improved APIs. Keep public API surfaces minimal by avoiding exposure of internal types that change frequently, focusing documentation on stable, user-facing interfaces only.
Enter the URL of a public GitHub repository