What is UI-Router Core?
UI-Router Core is a powerful, framework-agnostic routing library for JavaScript Single Page Applications (SPAs). It provides a state-based approach to routing that goes beyond simple URL matching, offering a complete state machine to manage transitions between application states.UI-Router Core is the foundation for framework-specific implementations including UI-Router for Angular 1, UI-Router for Angular 2+, and UI-Router for React.
Why UI-Router Core?
Unlike traditional routers that simply map URLs to components, UI-Router models your application as a hierarchical tree of states. Each state represents a place in your application with its own URL, data requirements, and UI components.Key Benefits
State-based routing
Model your application as a tree of named states rather than just URL patterns
Framework agnostic
Use the same routing core across Angular, React, Vue, or vanilla JavaScript
Powerful transitions
Transaction-like state transitions with lifecycle hooks and async support
Flexible URLs
Support for path, query, and hash parameters with custom encoding/decoding
Core Features
Hierarchical State Machine
UI-Router uses a state machine to manage transitions between application states. States can be nested, allowing you to build complex application structures with inherited properties.Named State Addressing
Navigate using state names rather than URLs, with support for both absolute and relative addressing:- Absolute:
admin.users - Relative:
.users(from current state)
Multiple Named Views
Define multiple UI regions that can be independently controlled:Typed Parameters
UI-Router supports typed URL parameters with built-in types and the ability to define custom parameter types:- Built-in types:
int,string,date,json,bool,path,query,hash - Optional or required parameters
- Default values with URL squashing
- Custom encoding/decoding
Resolve - Async Data Fetching
Fetch data asynchronously before entering a state, with dependency injection support:Transition Lifecycle Hooks
Attach behavior at any point during a state transition:onBefore- Before the transition startsonStart- As the transition startsonEnter- When entering a stateonRetain- When a state is retained (not exited/entered)onExit- When exiting a stateonFinish- After the transition succeedsonSuccess- Alias for onFinishonError- When transition fails
Framework Agnostic Design
UI-Router Core is designed to work with any JavaScript framework or none at all. It provides the core routing logic while framework-specific adapters handle the integration:Architecture Overview
The UIRouter class provides access to all core services:Use Cases
UI-Router Core excels at:Complex Single Page Applications
Complex Single Page Applications
Build applications with deeply nested routes, multiple views, and complex navigation patterns. The hierarchical state structure naturally maps to complex UI layouts.
Framework Migration
Framework Migration
Since UI-Router Core is framework-agnostic, you can maintain consistent routing logic when migrating between frameworks or supporting multiple frameworks.
Custom Router Implementation
Custom Router Implementation
Use UI-Router Core as the foundation for building custom routers for new frameworks or specialized use cases. Implement UIView, UISref, and framework-specific bootstrapping.
Data-Driven Applications
Data-Driven Applications
Leverage resolve dependencies to fetch data before rendering views, ensuring your components always have the data they need.
Next Steps
Ready to get started? Follow our installation and quickstart guides:Installation
Install UI-Router Core in your project
Quickstart
Build your first router in minutes
Core Concepts
Learn about states, transitions, and URLs
API Reference
Explore the complete API documentation
Community and Support
GitHub
Report issues and contribute to the project
Stack Overflow
Get help from the community