Skip to content
Back to skills

Ux Native

ASecurity

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.

  • 191 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 2, 2026
ai-agentsjavascriptgojavaphpbashapidocumentation

Works with

  • cli
  • api

Security analysis

A100/100

Scanned December 2, 2026

npx -y skills add smnandre/symfony-ux-skills --skill ux-native --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ux Native?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ux Native
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/smnandre-ux-native/badge)](https://www.skillsdirectory.com/skills/smnandre-ux-native)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ux-native
description: '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.'
license: MIT
metadata:
  author: Simon André
  url: https://smnandre.dev
---

# UX Native

Serve a [Hotwire Native](https://native.hotwired.dev/) 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.

The package is **experimental**: its API may still change. It builds on Turbo (`symfony/ux-turbo`).

## Installation

```bash
composer require symfony/ux-native
```

Flex adds `@hotwired/hotwire-native-bridge` and `@hotwired/stimulus` to `importmap.php` (AssetMapper) or `package.json` (Encore, Reprise).

## Quick Reference

```
{% if ux_is_native() %}                         Request from the app (User-Agent contains "Hotwire Native")
NativeNavigator::isNative()                     Same check in PHP
#[AsNativeConfigurationProvider]                Class holding path configurations
#[AsNativeConfiguration('/config/ios_v1.json')] Method returning a Configuration
php bin/console ux:native:build-configs         Write the JSON files for production
NativeNavigator::redirectOrToRoute(...)         Dismiss / refresh in the app, redirect in a browser
php bin/console make:native-bridge-controller   Bridge component skeleton
```

## Native or Browser

```twig
{% if not ux_is_native() %}
    {{ include('_navbar.html.twig') }}    {# the app shows its own navigation #}
{% endif %}
```

```php
use Symfony\UX\Native\Navigation\NativeNavigator;

public function show(NativeNavigator $navigator): Response
{
    $template = $navigator->isNative() ? 'note/show_native.html.twig' : 'note/show.html.twig';
    // ...
}
```

Every Hotwire Native client sends `Hotwire Native` in its `User-Agent`; the bundle flags the request on `kernel.request`. Outside a request (console, workers), `ux_is_native()` returns `false`.

## Path Configuration

The app downloads JSON describing how to present each URL (modal, pull to refresh, native screen). Declare each file as a method:

```php
namespace App\Native;

use Symfony\UX\Native\Attribute\AsNativeConfiguration;
use Symfony\UX\Native\Attribute\AsNativeConfigurationProvider;
use Symfony\UX\Native\Configuration\Configuration;
use Symfony\UX\Native\Configuration\Rule;

#[AsNativeConfigurationProvider]
final class PathConfiguration
{
    #[AsNativeConfiguration('/config/ios_v1.json')]
    public function iosV1(): Configuration
    {
        return new Configuration(
            settings: ['feature_flags' => ['new_editor' => true]],
            rules: [
                new Rule(patterns: ['.*'], properties: ['context' => 'default', 'pull_to_refresh_enabled' => true]),
                new Rule(patterns: ['/new$', '/edit$'], properties: ['context' => 'modal', 'pull_to_refresh_enabled' => false]),
            ],
        );
    }

    #[AsNativeConfiguration('/config/android_v1.json')]
    public function androidV1(): Configuration
    {
        return $this->iosV1();
    }
}
```

Methods must be public, non-static and return `Configuration`. `settings` and rule `properties` are free-form arrays: the keys (`context`, `pull_to_refresh_enabled`, `uri`, `presentation`...) are the ones the [Hotwire Native path configuration](https://native.hotwired.dev/reference/path-configuration) understands. Version the paths (`ios_v1.json`) so an old app release keeps its file.

Without attributes, tag a `Configuration` service with `ux_native.configuration` and a `path`:

```yaml
services:
    app.native.ios_v1:
        class: Symfony\UX\Native\Configuration\Configuration
        factory: ['@App\Native\PathConfiguration', 'iosV1']
        tags:
            - { name: ux_native.configuration, path: /config/ios_v1.json }
```

**Development:** in debug mode, the bundle answers these paths on the fly from the PHP objects: edit and reload the app.

**Production:** write the files to disk as part of the deployment, so the web server serves them statically:

```bash
php bin/console ux:native:build-configs    # public/config/ios_v1.json, public/config/android_v1.json
```

```yaml
# config/packages/ux_native.yaml
ux_native:
    output_dir: '%kernel.project_dir%/public'   # default
```

## Navigating After a Form

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+, `NativeNavigator` redirects the app to a historical location that Hotwire Native 1.2+ intercepts, and a browser to a regular page:

```yaml
# config/routes/ux_native.yaml
ux_native:
    resource: '@UXNativeBundle/config/routes.php'
```

```php
use Symfony\UX\Native\Navigation\HistoricalLocation;
use Symfony\UX\Native\Navigation\NativeNavigator;

#[Route('/notes/new', name: 'app_note_new', methods: ['GET', 'POST'])]
public function new(Request $request, NativeNavigator $navigator): Response
{
    // ... handle the form
    if ($form->isSubmitted() && $form->isValid()) {
        $this->addFlash('success', 'Note created!');

        return $navigator->redirectOrToRoute(HistoricalLocation::Refresh, 'app_notes');
    }
    // ...
}
```

| Location | In the app |
|----------|-----------|
| `HistoricalLocation::Recede` | Dismiss the modal, or go back one screen |
| `HistoricalLocation::Refresh` | Dismiss the modal, then reload the visible screen |
| `HistoricalLocation::Resume` | Dismiss the modal and stay |

| Method | In a browser |
|--------|--------------|
| `redirectOrToRoute($location, $route, $parameters)` | Redirect to the route |
| `redirectOr($location, $url)` | Redirect to the URL |
| `redirectOrBackOr($location, $fallbackUrl)` | Redirect to the same-origin `Referer`, else the fallback |
| `redirect($location)` | Throws `LogicException`: call it only after `isNative()` |

All of them answer `303 See Other`, as Turbo expects after a form. Flash messages survive to the reloaded screen.

## Bridge Controllers

[Hotwire Native Bridge](https://native.hotwired.dev/reference/bridge-installation) lets a Stimulus controller talk to native code (a native submit button, a menu, a share sheet). Requires `symfony/maker-bundle`:

```bash
php bin/console make:native-bridge-controller contact_form
```

```javascript
// assets/controllers/contact_form_controller.js
import { BridgeComponent } from '@hotwired/hotwire-native-bridge';

export default class extends BridgeComponent {
    static component = 'contact_form';    // must match the component registered in the app

    connect() {
        super.connect();
    }

    disconnect() {
        super.disconnect();
    }
}
```

```twig
<form data-controller="contact-form">...</form>
```

## Gotchas

- `redirectOr*()` without the imported routes fails with a missing `ux_native_*_historical_location` route. A route prefix works (`/app/refresh_historical_location`); keep the path names themselves, since the apps match them exactly.
- In production, skip `ux:native:build-configs` and the app gets a 404 for its configuration: run it on every deploy.
- Pages differ between the app and browsers for the same URL: behind a shared HTTP cache, add `Vary: User-Agent` or keep those responses private.
- Hide web navigation with `ux_is_native()`; leave content and forms shared, so one Turbo page serves both.

## References

- [Symfony UX package and app examples](https://ux.symfony.com/native) ([Markdown summary](https://ux.symfony.com/native.md)) · [`symfony/ux-native` on Packagist](https://packagist.org/packages/symfony/ux-native).
- For path configuration, bridge controllers and native navigation, see the [Symfony UX Native documentation](https://symfony.com/bundles/ux-native).
- For how the iOS and Android adapters match URLs to navigation rules, see [Hotwire Native path configuration](https://native.hotwired.dev/overview/path-configuration).

## See Also

- **turbo**: Drive, Frames and Streams power every screen of the app
- **stimulus**: Bridge components are Stimulus controllers

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.