Single Page Application Routing
single page application spa routing
Implementation
github.
Routing Strategies
Location Hash
https://debuggerjs.com/#path/to/route
Pros
-
You can easily detect a URL change by listening to the
onhashchange
event.
Cons
Location Path
https://debuggerjs.com/path/to/route
Pros
Cons
- Not easy to detect URL changes.
- Requires special server configuration.
Location Search
https://debuggerjs.com/?path/to/route
Pros
- Does not require special server configuration
Cons
- Not easy to detect URL changes.
- .
History API
Navigation Events
Popstate
The popstate
event
PushState
Detecting Push State Events
Persisting Route State
Handling Url Hash
Determining Active Url