--- name: app-development description: Build Shopify apps with extensions and embedded experiences. Use this skill for creating new Shopify apps, adding app extensions, building admin interfaces, working with OAuth authentication, managing app configuration, and deploying to the Shopify App Store. Covers Shopify CLI for apps, Polaris UI, and app bridge. license: MIT compatibility: Requires Shopify CLI, Node.js 18+, and a Shopify Partner account metadata: author: shopify-agent-skills version: "1.0" shopify-api-version: "2025-01" --- # Shopify App Development ## When to use this skill Use this skill when: - Creating a new Shopify app - Building app extensions (admin, checkout, etc.) - Embedding UI in the Shopify admin - Working with OAuth and app authentication - Managing webhooks and app events - Using Shopify Polaris UI components - Deploying apps to the Shopify App Store ## App Types ### Public Apps - Distributed via the Shopify App Store - Available to all merchants - Require app review process ### Custom Apps - Built for a single merchant/organization - Direct installation (no app store) - Simpler distribution ### Sales Channel Apps - Integrate a sales channel with Shopify - Appear in the Shopify admin's sales channels ## Getting Started ### 1. Create a New App ```bash # Initialize a new app shopify app init # Choose a template: # - Remix (recommended) # - Node # - Ruby # - PHP ``` ### 2. Project Structure (Remix Template) ``` my-app/ ├── app/ │ ├── routes/ │ │ ├── app._index.jsx # Main app page │ │ ├── app.products.jsx # Products page │ │ └── webhooks.jsx # Webhook handlers │ ├── shopify.server.js # Shopify API config │ └── root.jsx # Root layout ├── extensions/ # App extensions ├── prisma/ # Database schema ├── shopify.app.toml # App configuration └── package.json ``` ### 3. Start Development ```bash # Start dev server with tunnel shopify app dev # View app info shopify app info ``` ## App Configuration ### shopify.app.toml ```toml name = "My App" client_id = "your-api-key" [access_scopes] scopes = "read_products, write_products, read_orders" [webhooks] api_version = "2025-01" [[webhooks.subscriptions]] topics = ["products/create", "orders/create"] uri = "/webhooks" [app_proxy] url = "https://myapp.example.com/proxy" subpath = "app-proxy" prefix = "apps" ``` ### Environment Variables ```env SHOPIFY_API_KEY=your-api-key SHOPIFY_API_SECRET=your-api-secret SCOPES=read_products,write_products HOST=https://your-tunnel-url.ngrok.io ``` ## Authentication ### Session Tokens (Recommended) Apps embedded in the Shopify admin use session tokens: ```javascript // app/shopify.server.js import "@shopify/shopify-app-remix/adapters/node"; import { AppDistribution, shopifyApp } from "@shopify/shopify-app-remix/server"; const shopify = shopifyApp({ apiKey: process.env.SHOPIFY_API_KEY, apiSecretKey: process.env.SHOPIFY_API_SECRET, scopes: process.env.SCOPES?.split(","), appUrl: process.env.SHOPIFY_APP_URL, distribution: AppDistribution.AppStore, }); export default shopify; ``` ### Admin API Access ```javascript import { authenticate } from "../shopify.server"; export async function loader({ request }) { const { admin } = await authenticate.admin(request); const response = await admin.graphql(` query { products(first: 10) { nodes { id title handle } } } `); const data = await response.json(); return json({ products: data.data.products.nodes }); } ``` ## App Extensions ### Extension Types | Type | Description | | ---------------- | ----------------------------------- | | **Admin UI** | Embedded UI in Shopify admin | | **Admin Action** | Action buttons in admin | | **Admin Block** | Content blocks in admin | | **Checkout UI** | Custom checkout experience | | **Theme App** | Integrate with merchant themes | | **POS UI** | Point of Sale extensions | | **Flow** | Workflow automation | | **Functions** | Backend logic (discounts, shipping) | ### Create an Extension ```bash # Generate an extension shopify app generate extension # Choose extension type from the list ``` ### Admin UI Extension Example ```jsx // extensions/admin-block/src/BlockExtension.jsx import { reactExtension, useApi, AdminBlock, Text, BlockStack, InlineStack, Button, } from "@shopify/ui-extensions-react/admin"; export default reactExtension("admin.product-details.block.render", () => ( )); function ProductBlock() { const { data } = useApi(); return ( Product ID: {data.selected[0]?.id} ); } ``` ### Theme App Extension ```jsx // extensions/theme-block/blocks/product-rating.liquid {% schema %} { "name": "Product Rating", "target": "section", "settings": [ { "type": "product", "id": "product", "label": "Product" } ] } {% endschema %}
{% javascript %} // Your JavaScript here {% endjavascript %} {% stylesheet %} .product-rating { padding: 16px; } {% endstylesheet %} ``` ## Polaris UI Components ### Basic Layout ```jsx import { Page, Layout, Card, Text, BlockStack, InlineStack, Button, TextField, Select, Banner, List, } from "@shopify/polaris"; export default function ProductPage() { return ( Product Details