Overview
UI-Router Core is framework-agnostic. To integrate it with a specific framework (React, Angular, Vue, etc.), you need to implement framework-specific adapters for views, directives/components, and location services.Architecture
A framework integration typically requires:- Location Services - Bridge between framework routing and browser URL
- View Components - Framework-specific
<ui-view>implementation - Link Components - Framework-specific
<ui-sref>implementation - Dependency Injection - Framework’s DI integration
- View Config Factory - Creates ViewConfig objects from state declarations
Implementing UIView
The<ui-view> component displays the active state’s view content.
ActiveUIView Interface
Your UIView implementation must register with the ViewService using this interface (from src/view/interface.ts:10-25):ViewContext Interface
React UIView Example
Angular UIView Example
Implementing UISref
The<ui-sref> component/directive creates links to states.
React UISref Example
Vue UISref Example
ViewConfig Factory
Framework integrations must register a ViewConfig factory that creates ViewConfig objects from state view declarations.State Declaration Extensions
Extend the StateDeclaration interface for framework-specific properties:Complete Integration Example
Best Practices
- Use unique
$typeidentifiers - Prevents view mismatches across frameworks - Implement proper cleanup - Deregister views and listeners in component unmount/destroy
- Handle fully qualified names (fqn) - Properly calculate nested view names
- Support lazy loading - Implement async component loading in ViewConfig.load()
- Integrate with framework DI - Map UI-Router resolves to framework dependency injection
- Provide TypeScript definitions - Export properly typed interfaces for state declarations
- Document framework-specific features - Clearly explain any framework-specific behavior
Reference Implementations
- Angular 1:
@uirouter/angularjs - Angular:
@uirouter/angular - React:
@uirouter/react - Vue:
@uirouter/vue