Intelligent Routing
Navigation shouldn't be hard. pp.redirect(url) acts as a smart traffic controller. It automatically detects if a link is internal or external and chooses the most performant navigation strategy.
Internal Routes
If the domain matches the current origin:
- Uses Soft Navigation (SPA)
-
•Fetches content via AJAX
-
•Updates DOM with View Transitions
External Links
If the domain is different (e.g., google.com):
- Uses Hard Navigation
-
•Sets
window.location.href -
•Full browser refresh
Usage Patterns
// 1. Internal: Smoothly transitions to the settings page
// Triggers loading states and view transitions automatically.
pp.redirect('/account/settings');
// 2. External: Standard browser redirect
// Automatically detects the different origin.
pp.redirect('https://stripe.com/checkout');
// 3. Query Params: Works perfectly with URL construction
const params = new URLSearchParams({ source: 'dashboard' });
pp.redirect(`/users?${params.toString()}`);
Decision Logic
The function uses the native URL API to parse the destination string relative to the current window origin.
| Input URL | Detected Type | Action Taken |
|---|---|---|
| /dashboard | Internal |
navigateTo() + Push State
|
| https://mysite.com/home | Internal (Same Origin) |
navigateTo() + Push State
|
| https://google.com | External |
window.location.href
|
| #top | Anchor | Smooth scroll to element ID |
Automatic Backend Handling
You rarely need to call this manually after a fetchFunction. If your PHP backend returns a redirect instruction (or a 302 status handled by the framework), PulsePoint automatically captures it and calls pp.redirect() for you.