hyva-alpine-component

Create CSP-safe Alpine.js components for Hyvä Magento 2 themes.

78|16|Updated Jan 22, 2026
One-click install
npx skills add https://github.com/hyva-themes/hyva-ai-tools --skill hyva-alpine-component
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: hyva-alpine-component
Source: https://github.com/hyva-themes/hyva-ai-tools/tree/main/skills/hyva-alpine-component
Command: npx skills add https://github.com/hyva-themes/hyva-ai-tools --skill hyva-alpine-component

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps Magento 2 developers craft CSP-safe Alpine.js components for Hyvä themes, ensuring interactivity without violating Content Security Policy.

Core Features & Use Cases

  • CSP-safe patterns for Hyvä Alpine components that work with Alpine CSP builds.
  • Guidance on secure registration with Alpine.data inside alpine:init and proper escaping of PHP values.
  • Use Case: Add a small interactive widget (e.g., tabbed content or modal) to a Hyvä template while maintaining CSP compliance.

Quick Start

Create a CSP-safe Alpine component by defining a named constructor function and registering it with Alpine.data inside an alpine:init listener, using {once: true} and escaping values appropriately.

Frequently Asked Questions about hyva-alpine-component

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build CSP-safe Alpine.js components for Hyvä themes?

To build CSP-safe Alpine.js components for Hyvä, register a named constructor function with Alpine.data inside an alpine:init event listener using {once: true}, ensuring PHP values are properly escaped. This pattern maintains strict Content Security Policy compliance.

Why does my Alpine.js component violate Content Security Policy in Magento 2?

Alpine.js components typically violate Content Security Policy when inline scripts execute eval statements or expose unsanitized data. You must register constructors securely via alpine:init and properly escape PHP values to meet CSP requirements.

What is the best way to register Alpine interactivity in a Hyvä template?

The best way to register Alpine interactivity in a Hyvä template is using Alpine.data within an alpine:init listener. This CSP-friendly pattern securely binds your named constructor functions without violating Content Security Policy.

Do I need to escape PHP values when creating Hyvä Alpine components?

Yes, you need to properly escape PHP values when creating Hyvä Alpine components to prevent CSP violations and security vulnerabilities. Proper escaping ensures dynamic data safely passes into the Alpine.js component architecture.

Can I use standard Alpine.js initialization with Magento 2 CSP builds?

Standard Alpine.js initialization often fails Magento 2 CSP builds because it relies on inline expressions. You must use CSP-safe patterns like registering constructors inside an alpine:init listener to maintain compliance.

When should I use the alpine:init listener for Hyvä theme development?

You should use the alpine:init listener whenever adding interactive widgets like tabbed content or modals to Hyvä templates. It ensures your components are registered securely and remain fully compliant with Magento CSP requirements.