/symfony-ux-skills:ux-nativefrom symfony-ux-skills
Builds Hotwire Native iOS and Android apps from Symfony sites. Handles native request detection, JSON path configuration, modal navigation, and bridge controller scaffolding.
Ships in symfony-ux-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Serve a Hotwire Native 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).
composer require symfony/ux-native
Flex adds @hotwired/hotwire-native-bridge and @hotwired/stimulus to importmap.php (AssetMapper) or package.json (Encore, Reprise).
{% 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
{% if not ux_is_native() %}
{{ include('_navbar.html.twig') }} {# the app shows its own navigation #}
{% endif %}
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.
The app downloads JSON describing how to present each URL (modal, pull to refresh, native screen). Declare each file as a method:
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 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:
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:
php bin/console ux:native:build-configs # public/config/ios_v1.json, public/config/android_v1.json
# config/packages/ux_native.yaml
ux_native:
output_dir: '%kernel.project_dir%/public' # default
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:
# config/routes/ux_native.yaml
ux_native:
resource: '@UXNativeBundle/config/routes.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.
Hotwire Native Bridge lets a Stimulus controller talk to native code (a native submit button, a menu, a share sheet). Requires symfony/maker-bundle:
php bin/console make:native-bridge-controller contact_form
// 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();
}
}
<form data-controller="contact-form">...</form>
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.ux:native:build-configs and the app gets a 404 for its configuration: run it on every deploy.Vary: User-Agent or keep those responses private.ux_is_native(); leave content and forms shared, so one Turbo page serves both.symfony/ux-native on Packagist.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub smnandre/symfony-ux-skills --plugin symfony-ux-skills20 skills in this plugin
/live-componentSymfony UX LiveComponent: live search, live filters, dependent selects and form validation as users type. Use for reactive PHP and Twig components, #[AsLiveComponent], LiveProp, LiveAction, data-model, loading states, emit/listen, lazy rendering and LiveResponse downloads./stimulusSymfony UX Stimulus: JavaScript behavior for dropdowns, tabs, modals, clipboard buttons and third-party widgets. Use for StimulusBundle, data-controller, data-action, targets, values, outlets, lazy controllers and Twig stimulus_* helpers./symfony-uxSymfony UX: choose and combine packages for a Symfony frontend. Use when deciding between Stimulus, Turbo, TwigComponent and LiveComponent, or fitting several Symfony UX packages into the same feature. Prefer the dedicated skill for a task that fits one package.Other plugins' skills for the same job