Skip to content

Routing

Haven supports client-side routing for navigating between category views and product/event detail without full page reloads.

Routing options

javascript
routing: {
  path: '/directory/',
  singlePath: '',
  type: 'hash',
  titleSep: ' | ',
  doPathChange: true,
  hashDocument: null,
}
OptionTypeDefaultDescription
pathstring/Base route path for this embed
singlePathstring''Segment before product nicename (e.g. item)
typestring''hash or path (empty disables routing type)
titleSepstring-Document title separator
doPathChangebooleanfalseEnable router onChange handler
hashDocumentstringnullEmbed hash routing on a different page path

Hash routing

URLs use hash fragments:

https://yoursite.com/directory/#/category-name/product-name

Configuration:

javascript
routing: {
  path: '/directory/',
  type: 'hash',
  doPathChange: true,
}

Advantages: No server configuration required. Works on any static host.

Considerations: Hash URLs are less SEO-friendly and may look less clean in the address bar.

Embed hash routing on another page

When the directory lives on a page with a different URL path, set hashDocument:

javascript
routing: {
  path: '/directory/',
  type: 'hash',
  doPathChange: false,
  hashDocument: '/directory/',
}

This is useful for itinerary sidebars embedded on a homepage.

Path routing

URLs use clean paths:

https://yoursite.com/directory2/category-name/product-name

Configuration:

javascript
routing: {
  path: '/directory2/',
  type: 'path',
  doPathChange: true,
}

Advantages: Clean, shareable URLs. Better for SEO.

Requirements: Server rewrite rules to route all requests to your app shell (index.html).

Apache (.htaccess)

apache
<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /directory2/

  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d

  RewriteRule ^ index.html [L]
</IfModule>

DirectoryIndex index.html

See Path Routing example.

Nginx

nginx
location /directory2/ {
  try_files $uri $uri/ /directory2/index.html;
}

Disabling routing

For widgets that should not change the URL:

javascript
routing: {
  path: '/directory/',
  type: 'hash',
  doPathChange: false,
}

Document title

Haven updates document.title as users navigate. The format is:

Product Name | Category Name | Your Page Title

Control the separator with titleSep.

Choosing a strategy

ScenarioRecommended
CMS iframe embedHash routing
Standalone SPA pagePath routing
Sidebar widget on homepageHash with doPathChange: false
Upcoming events widgetRouting optional (minimal navigation)

Haven Destinations integration documentation