Stateful, hierarchical router for single page applications