Skip to content

Path Configuration

The basics of Path Configuration are explained in the overview. If you’re ready to build your first Path Configuration, keep reading.

Settings

settings is your sandbox for App-level configuration. As explained in the overview, common use cases include feature flags or any additional information that your app may use to configure itself. Feel free to add or modify any objects or arrays here, always remembering to version your path configuration if you make breaking changes.

{
"settings": {
"use_local_db": true,
"cable": {
"script_url": "https://hotwire-native-demo.dev/configurations/action_cable.js"
},
"feature_flags": [
{
"name": "new_onboarding_flow",
"enabled": true
}
]
}
"rules": []
}

Rules

rules contains individual entries that define how different URL path patterns should behave. Each rule consists of the patterns to match and the properties to apply.

{
"settings": {},
"rules": [
{
patterns: "",
properties: {}
}
]
}

Entries in rules are read sequentially and are applied to the caught URL (via path pattern regex matching) as they are read. This means that rules earlier in the array can be overwritten by rules further down the array. It’s recommended that the first rule should establish the default behavior for all patterns and subsequent rules can override this for specific behavior.

The following Path Configuration shows how a rule further down the array can override properties set by previous rules. Notice property pull_to_refresh_enabled is true for all URLs but false for URL path patterns matching "/new$".

{
"settings": {},
"rules": [
{
"patterns": [
".*"
],
"properties": {
"context": "default",
"pull_to_refresh_enabled": true
}
},
{
"patterns": [
"/new$"
],
"properties": {
"context": "modal",
"pull_to_refresh_enabled": false
}
}
]
}

Using the above Path Configuration, when a navigation is requested to "/":

  1. Path Configuration matches "/" to the first rule ".*"
  2. Path Configuration sets pull_to_refresh_enabled = true
  3. Since the second rule does not match the URL path pattern, it is ignored.

However, when navigation is requested to "/new":

  1. Path Configuration matches "/new" to the first rule ".*"
  2. Path Configuration sets pull_to_refresh_enabled = true
  3. Path Configuration matches "/new" to the second rule "/new$"
  4. Path Configuration sets pull_to_refresh_enabled = fase

A rule earlier in the array can be overwritten by rules further down the array.

Patterns

The patterns array defines regular expression patterns that will be used to match URL paths.

Properties

The properties hash contains a handful of key/value pairs that Hotwire Native supports out of the box.

You are free to add more properties as your app needs, but these are the ones the framework is aware of and will handle automatically.

Android-specific properties

iOS-specific properties

Next: Bridge Installation