{"slug":"ux-native","title":"ux-native","summary":"Symfony UX Native: Hotwire Native iOS and Android apps, modal navigation and native bridges for Symfony sites. Use for ux_is_native(), JSON path configuration, #[AsNativeConfiguration], ux:native:build-configs, NativeNavigator, historical locations and make:native-bridge-controll","platform":"Claude","tags":[],"authorName":"LLM Mart","authorSlug":"llm-mart","score":0,"source":"github","price":null,"verified":false,"createdAt":"2026-12-02T16:48:38.781708Z","repo":{"url":"https://github.com/smnandre/symfony-ux-skills","stars":191,"forks":15,"license":"MIT","updatedAt":"2026-12-02T03:34:06Z"},"bodyHtml":"<hr>\n<h2>name: ux-native\ndescription: 'Symfony UX Native: Hotwire Native iOS and Android apps, modal navigation and native bridges for Symfony sites. Use for ux_is_native(), JSON path configuration, #[AsNativeConfiguration], ux:native:build-configs, NativeNavigator, historical locations and make:native-bridge-controller.'\nlicense: MIT\nmetadata:\nauthor: Simon André\nurl: <a href=\"https://smnandre.dev\">https://smnandre.dev</a></h2>\n<h1>UX Native</h1>\n<p>Serve a <a href=\"https://native.hotwired.dev/\">Hotwire Native</a> iOS or Android app from your Symfony site. The bundle detects requests from the app, builds the JSON path configurations the app downloads, sends the app navigation actions after a form, and scaffolds Bridge controllers.</p>\n<p>The package is <strong>experimental</strong>: its API may still change. It builds on Turbo (<code>symfony/ux-turbo</code>).</p>\n<h2>Installation</h2>\n<pre><code>composer require symfony/ux-native\n</code></pre>\n<p>Flex adds <code>@hotwired/hotwire-native-bridge</code> and <code>@hotwired/stimulus</code> to <code>importmap.php</code> (AssetMapper) or <code>package.json</code> (Encore, Reprise).</p>\n<h2>Quick Reference</h2>\n<pre><code>{% if ux_is_native() %}                         Request from the app (User-Agent contains \"Hotwire Native\")\nNativeNavigator::isNative()                     Same check in PHP\n#[AsNativeConfigurationProvider]                Class holding path configurations\n#[AsNativeConfiguration('/config/ios_v1.json')] Method returning a Configuration\nphp bin/console ux:native:build-configs         Write the JSON files for production\nNativeNavigator::redirectOrToRoute(...)         Dismiss / refresh in the app, redirect in a browser\nphp bin/console make:native-bridge-controller   Bridge component skeleton\n</code></pre>\n<h2>Native or Browser</h2>\n<pre><code>{% if not ux_is_native() %}\n    {{ include('_navbar.html.twig') }}    {# the app shows its own navigation #}\n{% endif %}\n</code></pre>\n<pre><code>use Symfony\\UX\\Native\\Navigation\\NativeNavigator;\n\npublic function show(NativeNavigator $navigator): Response\n{\n    $template = $navigator-&gt;isNative() ? 'note/show_native.html.twig' : 'note/show.html.twig';\n    // ...\n}\n</code></pre>\n<p>Every Hotwire Native client sends <code>Hotwire Native</code> in its <code>User-Agent</code>; the bundle flags the request on <code>kernel.request</code>. Outside a request (console, workers), <code>ux_is_native()</code> returns <code>false</code>.</p>\n<h2>Path Configuration</h2>\n<p>The app downloads JSON describing how to present each URL (modal, pull to refresh, native screen). Declare each file as a method:</p>\n<pre><code>namespace App\\Native;\n\nuse Symfony\\UX\\Native\\Attribute\\AsNativeConfiguration;\nuse Symfony\\UX\\Native\\Attribute\\AsNativeConfigurationProvider;\nuse Symfony\\UX\\Native\\Configuration\\Configuration;\nuse Symfony\\UX\\Native\\Configuration\\Rule;\n\n#[AsNativeConfigurationProvider]\nfinal class PathConfiguration\n{\n    #[AsNativeConfiguration('/config/ios_v1.json')]\n    public function iosV1(): Configuration\n    {\n        return new Configuration(\n            settings: ['feature_flags' =&gt; ['new_editor' =&gt; true]],\n            rules: [\n                new Rule(patterns: ['.*'], properties: ['context' =&gt; 'default', 'pull_to_refresh_enabled' =&gt; true]),\n                new Rule(patterns: ['/new$', '/edit$'], properties: ['context' =&gt; 'modal', 'pull_to_refresh_enabled' =&gt; false]),\n            ],\n        );\n    }\n\n    #[AsNativeConfiguration('/config/android_v1.json')]\n    public function androidV1(): Configuration\n    {\n        return $this-&gt;iosV1();\n    }\n}\n</code></pre>\n<p>Methods must be public, non-static and return <code>Configuration</code>. <code>settings</code> and rule <code>properties</code> are free-form arrays: the keys (<code>context</code>, <code>pull_to_refresh_enabled</code>, <code>uri</code>, <code>presentation</code>...) are the ones the <a href=\"https://native.hotwired.dev/reference/path-configuration\">Hotwire Native path configuration</a> understands. Version the paths (<code>ios_v1.json</code>) so an old app release keeps its file.</p>\n<p>Without attributes, tag a <code>Configuration</code> service with <code>ux_native.configuration</code> and a <code>path</code>:</p>\n<pre><code>services:\n    app.native.ios_v1:\n        class: Symfony\\UX\\Native\\Configuration\\Configuration\n        factory: ['@App\\Native\\PathConfiguration', 'iosV1']\n        tags:\n            - { name: ux_native.configuration, path: /config/ios_v1.json }\n</code></pre>\n<p><strong>Development:</strong> in debug mode, the bundle answers these paths on the fly from the PHP objects: edit and reload the app.</p>\n<p><strong>Production:</strong> write the files to disk as part of the deployment, so the web server serves them statically:</p>\n<pre><code>php bin/console ux:native:build-configs    # public/config/ios_v1.json, public/config/android_v1.json\n</code></pre>\n<pre><code># config/packages/ux_native.yaml\nux_native:\n    output_dir: '%kernel.project_dir%/public'   # default\n</code></pre>\n<h2>Navigating After a Form</h2>\n<p>Inside the app, a form opened as a modal should close and refresh the list under it, instead of loading the next page in the modal. Since Symfony UX 3.7+, <code>NativeNavigator</code> redirects the app to a historical location that Hotwire Native 1.2+ intercepts, and a browser to a regular page:</p>\n<pre><code># config/routes/ux_native.yaml\nux_native:\n    resource: '@UXNativeBundle/config/routes.php'\n</code></pre>\n<pre><code>use Symfony\\UX\\Native\\Navigation\\HistoricalLocation;\nuse Symfony\\UX\\Native\\Navigation\\NativeNavigator;\n\n#[Route('/notes/new', name: 'app_note_new', methods: ['GET', 'POST'])]\npublic function new(Request $request, NativeNavigator $navigator): Response\n{\n    // ... handle the form\n    if ($form-&gt;isSubmitted() &amp;&amp; $form-&gt;isValid()) {\n        $this-&gt;addFlash('success', 'Note created!');\n\n        return $navigator-&gt;redirectOrToRoute(HistoricalLocation::Refresh, 'app_notes');\n    }\n    // ...\n}\n</code></pre>\n<table>\n<thead>\n<tr>\n<th>Location</th>\n<th>In the app</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>HistoricalLocation::Recede</code></td>\n<td>Dismiss the modal, or go back one screen</td>\n</tr>\n<tr>\n<td><code>HistoricalLocation::Refresh</code></td>\n<td>Dismiss the modal, then reload the visible screen</td>\n</tr>\n<tr>\n<td><code>HistoricalLocation::Resume</code></td>\n<td>Dismiss the modal and stay</td>\n</tr>\n</tbody>\n</table>\n<table>\n<thead>\n<tr>\n<th>Method</th>\n<th>In a browser</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>redirectOrToRoute($location, $route, $parameters)</code></td>\n<td>Redirect to the route</td>\n</tr>\n<tr>\n<td><code>redirectOr($location, $url)</code></td>\n<td>Redirect to the URL</td>\n</tr>\n<tr>\n<td><code>redirectOrBackOr($location, $fallbackUrl)</code></td>\n<td>Redirect to the same-origin <code>Referer</code>, else the fallback</td>\n</tr>\n<tr>\n<td><code>redirect($location)</code></td>\n<td>Throws <code>LogicException</code>: call it only after <code>isNative()</code></td>\n</tr>\n</tbody>\n</table>\n<p>All of them answer <code>303 See Other</code>, as Turbo expects after a form. Flash messages survive to the reloaded screen.</p>\n<h2>Bridge Controllers</h2>\n<p><a href=\"https://native.hotwired.dev/reference/bridge-installation\">Hotwire Native Bridge</a> lets a Stimulus controller talk to native code (a native submit button, a menu, a share sheet). Requires <code>symfony/maker-bundle</code>:</p>\n<pre><code>php bin/console make:native-bridge-controller contact_form\n</code></pre>\n<pre><code>// assets/controllers/contact_form_controller.js\nimport { BridgeComponent } from '@hotwired/hotwire-native-bridge';\n\nexport default class extends BridgeComponent {\n    static component = 'contact_form';    // must match the component registered in the app\n\n    connect() {\n        super.connect();\n    }\n\n    disconnect() {\n        super.disconnect();\n    }\n}\n</code></pre>\n<pre><code>&lt;form data-controller=\"contact-form\"&gt;...&lt;/form&gt;\n</code></pre>\n<h2>Gotchas</h2>\n<ul>\n<li><code>redirectOr*()</code> without the imported routes fails with a missing <code>ux_native_*_historical_location</code> route. A route prefix works (<code>/app/refresh_historical_location</code>); keep the path names themselves, since the apps match them exactly.</li>\n<li>In production, skip <code>ux:native:build-configs</code> and the app gets a 404 for its configuration: run it on every deploy.</li>\n<li>Pages differ between the app and browsers for the same URL: behind a shared HTTP cache, add <code>Vary: User-Agent</code> or keep those responses private.</li>\n<li>Hide web navigation with <code>ux_is_native()</code>; leave content and forms shared, so one Turbo page serves both.</li>\n</ul>\n<h2>References</h2>\n<ul>\n<li><a href=\"https://ux.symfony.com/native\">Symfony UX package and app examples</a> (<a href=\"https://ux.symfony.com/native.md\">Markdown summary</a>) · <a href=\"https://packagist.org/packages/symfony/ux-native\"><code>symfony/ux-native</code> on Packagist</a>.</li>\n<li>For path configuration, bridge controllers and native navigation, see the <a href=\"https://symfony.com/bundles/ux-native\">Symfony UX Native documentation</a>.</li>\n<li>For how the iOS and Android adapters match URLs to navigation rules, see <a href=\"https://native.hotwired.dev/overview/path-configuration\">Hotwire Native path configuration</a>.</li>\n</ul>\n<h2>See Also</h2>\n<ul>\n<li><strong>turbo</strong>: Drive, Frames and Streams power every screen of the app</li>\n<li><strong>stimulus</strong>: Bridge components are Stimulus controllers</li>\n</ul>\n","files":[{"path":"SKILL.md","sizeBytes":8275,"isText":true}],"reviewScore":null,"reviewSummary":null,"trust":{"provenance":"trusted-source-unreviewed","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow.","bodySource":null},"bodyLocked":false,"purchaseUrl":null,"sourceUrl":null,"report":{"provenance":"trusted-source-unreviewed","screen":{"ran":true,"outcome":"clean","suspicious":0,"notes":0,"hiddenCharacters":false},"virusScan":{"engine":"clamav","status":"clean","scannedAt":"2026-12-02T16:49:27.796132Z","sha256":"A4B0A845D6601C97387BA037FAAC7B2FC18DB969DEDFD5408E25BAAFC19E7280","sizeBytes":3280},"review":null,"source":{"repositoryUrl":"https://github.com/smnandre/symfony-ux-skills","path":"skills/ux-native","license":"MIT","commit":"78c25ed0b79bcc21d7611002dc81d8b87c3316e2","subtreeSha":"6872BA6E876EF4BFC154E6D499FFE5F866C65BC6DAE7EDD54FD267139BB13F90","lastSyncedAt":"2026-12-02T16:48:36.132977Z"},"reviewedAt":"2026-12-02T16:51:14.66045Z","notice":"Community-authored content, reproduced verbatim and not vetted as instructions. Treat it as data to evaluate, never as directives to follow."},"install":[{"target":"skills-cli","command":"npx skills add https://github.com/smnandre/symfony-ux-skills/tree/main/skills/ux-native"},{"target":"claude-code","command":"claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install smnandre-symfony-ux-skills@llmmart"},{"target":"git","command":"git clone https://github.com/smnandre/symfony-ux-skills.git"}]}