A hierarchical stateful router for JavaScript applications