vtex-io-react-apps
Apply when building React components under react/ or configuring store blocks in store/ for VTEX IO apps. Covers interfaces.json, contentSchemas.json for Site Editor, VTEX Styleguide for admin apps, and css-handles for storefront styling. Use for creating custom storefront components, admin panels, pixel apps, or any frontend development within the VTEX IO react builder ecosystem.
What this skill does
# Frontend React Components & Hooks ## When this skill applies Use this skill when building VTEX IO frontend apps using the `react` builder — creating React components that integrate with Store Framework as theme blocks, configuring `interfaces.json`, setting up `contentSchemas.json` for Site Editor, and applying styling patterns. - Creating custom storefront components (product displays, forms, banners) - Building admin panel interfaces with VTEX Styleguide - Registering components as Store Framework blocks - Exposing component props in Site Editor via `contentSchemas.json` - Applying `css-handles` for safe storefront styling Do not use this skill for: - Backend service implementation (use `vtex-io-service-apps` instead) - GraphQL schema and resolver development (use `vtex-io-graphql-api` instead) - Manifest and builder configuration (use `vtex-io-app-structure` instead) ## Decision rules - Every visible storefront element is a **block**. Blocks are declared in theme JSON and map to React components via **interfaces**. - `interfaces.json` (in `/store`) maps block names to React component files: `"component"` is the file name in `/react` (without extension), `"allowed"` lists child blocks, `"composition"` controls how children work (`"children"` or `"blocks"`). - Each exported component MUST have a root-level file in `/react` that re-exports it. The builder resolves `"component": "ProductReviews"` to `react/ProductReviews.tsx`. - For **storefront** components, use `vtex.css-handles` for styling (not inline styles, not global CSS). - For **admin** components, use `vtex.styleguide` — the official VTEX Admin component library. No third-party UI libraries. - Use `contentSchemas.json` in `/store` to make component props editable in Site Editor (JSON Schema format). Merchant edits are stored by `vtex.pages-graphql` under a key that includes the **declaring app's MAJOR version** (`[email protected]:template`). A major version bump on the declaring app makes those edits invisible to the resolver until they are migrated to the new major with the `updateThemeIds` mutation in `[email protected]` — see `vtex-io-storefront-theme-versioning`. - Use `react-intl` and the `messages` builder for i18n — never hardcode user-facing strings. - Fetch data via GraphQL queries (`useQuery` from `react-apollo`), never via direct API calls from the browser. Architecture: ```text Store Theme (JSON blocks) └── declares "product-reviews" block with props │ ▼ interfaces.json → maps "product-reviews" to "ProductReviews" component │ ▼ react/ProductReviews.tsx → React component renders │ ├── useCssHandles() → CSS classes for styling ├── useQuery() → GraphQL data fetching └── useProduct() / useOrderForm() → Store Framework context hooks ``` ## Hard constraints ### Constraint: Declare Interfaces for All Storefront Blocks Every React component that should be usable as a Store Framework block MUST have a corresponding entry in `store/interfaces.json`. Without the interface declaration, the block cannot be referenced in theme JSON files. **Why this matters** The store builder resolves block names to React components through `interfaces.json`. If a component has no interface, it is invisible to Store Framework and will not render on the storefront. **Detection** If a React component in `/react` is intended for storefront use but has no matching entry in `store/interfaces.json`, warn the developer. The component will compile but never render. **Correct** ```json { "product-reviews": { "component": "ProductReviews", "composition": "children", "allowed": ["product-review-item"] }, "product-review-item": { "component": "ReviewItem" } } ``` ```tsx // react/ProductReviews.tsx import ProductReviews from './components/ProductReviews' export default ProductReviews ``` **Wrong** ```tsx // react/ProductReviews.tsx exists but NO store/interfaces.json entry // The component compiles fine but cannot be used in any theme. // Adding <product-reviews /> in a theme JSON will produce: // "Block 'product-reviews' not found" import ProductReviews from './components/ProductReviews' export default ProductReviews ``` --- ### Constraint: Use VTEX Styleguide for Admin UIs Admin panel components (apps using the `admin` builder) MUST use VTEX Styleguide (`vtex.styleguide`) for UI elements. You MUST NOT use third-party UI libraries like Material UI, Chakra UI, or Ant Design in admin apps. **Why this matters** VTEX Admin has a consistent design language enforced by Styleguide. Third-party UI libraries produce inconsistent visuals, may conflict with the Admin's global CSS, and add unnecessary bundle size. Apps submitted to the VTEX App Store with non-Styleguide admin UIs will fail review. **Detection** If you see imports from `@material-ui`, `@chakra-ui/react`, `@chakra-ui`, `antd`, or `@ant-design` in an admin app, warn the developer to use `vtex.styleguide` instead. **Correct** ```tsx // react/admin/ReviewModeration.tsx import React, { useState } from 'react' import { Layout, PageHeader, Table, Button, Tag, Modal, Input, } from 'vtex.styleguide' interface Review { id: string author: string rating: number text: string status: 'pending' | 'approved' | 'rejected' } function ReviewModeration() { const [reviews, setReviews] = useState<Review[]>([]) const [modalOpen, setModalOpen] = useState(false) const tableSchema = { properties: { author: { title: 'Author', width: 200 }, rating: { title: 'Rating', width: 100 }, text: { title: 'Review Text' }, status: { title: 'Status', width: 150, cellRenderer: ({ cellData }: { cellData: string }) => ( <Tag type={cellData === 'approved' ? 'success' : 'error'}> {cellData} </Tag> ), }, }, } return ( <Layout fullWidth pageHeader={<PageHeader title="Review Moderation" />}> <Table items={reviews} schema={tableSchema} density="medium" /> </Layout> ) } export default ReviewModeration ``` **Wrong** ```tsx // react/admin/ReviewModeration.tsx import React from 'react' import { DataGrid } from '@material-ui/data-grid' import { Button } from '@material-ui/core' // Material UI components will look inconsistent in the VTEX Admin, // conflict with global styles, and inflate bundle size. // This app will fail VTEX App Store review. function ReviewModeration() { return ( <div> <DataGrid rows={[]} columns={[]} /> <Button variant="contained" color="primary">Approve</Button> </div> ) } ``` --- ### Constraint: Export Components from react/ Root Level Every Store Framework block component MUST have a root-level export file in the `/react` directory that matches the `component` value in `interfaces.json`. The actual implementation can live in subdirectories, but the root file must exist. **Why this matters** The react builder resolves components by looking for files at the root of `/react`. If `interfaces.json` declares `"component": "ProductReviews"`, the builder looks for `react/ProductReviews.tsx`. Without this root export file, the component will not be found and the block will fail to render. **Detection** If `interfaces.json` references a component name that does not have a matching file at the root of `/react`, STOP and create the export file. **Correct** ```tsx // react/ProductReviews.tsx — root-level export file import ProductReviews from './components/ProductReviews/index' export default ProductReviews ``` ```tsx // react/components/ProductReviews/index.tsx — actual implementation import React from 'react' import { useCssHandles } from 'vtex.css-handles' const CSS_HANDLES = ['container', 'title', 'list'] as const interface Props { title: string maxReviews: number } function ProductReviews({ title, maxReviews }: Props) { const handles = useCssHa
Related in Web Dev
generating-lwc-components
IncludedLightning Web Components with PICKLES methodology and 165-point scoring. Use this skill when the user creates or edits LWC components, builds wire service patterns, or writes Jest tests for LWC. TRIGGER when: user creates/edits LWC components, touches lwc/**/*.js, .html, .css, .js-meta.xml files, or asks about wire service, SLDS, or Jest LWC tests. DO NOT TRIGGER when: Apex classes (use generating-apex), Aura components, or Visualforce.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Set up queries with useQuery, mutations with useMutation, configure QueryClient caching strategies, implement optimistic updates, and handle infinite scroll with useInfiniteQuery. Use when: setting up data fetching in React projects, migrating from v4 to v5, or fixing object syntax required errors, query callbacks removed issues, cacheTime renamed to gcTime, isPending vs isLoading confusion, keepPreviousData removed problems.
document-processor-api
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
nutrient-document-processing
IncludedProcess documents with Nutrient DWS. Use when the user wants to generate PDFs from HTML or URLs, convert Office/images/PDFs, assemble or split packets, OCR scans, extract text/tables/key-value pairs, redact PII, watermark, sign, fill forms, optimize PDFs, or produce compliance outputs like PDF/A or PDF/UA. Triggers include convert to PDF, merge these PDFs, OCR this scan, extract tables, redact PII, sign this PDF, make this PDF/A, or linearize for web delivery.
tanstack-query
IncludedManage server state in React with TanStack Query v5. Covers useMutationState, simplified optimistic updates, throwOnError, network mode (offline/PWA), and infiniteQueryOptions. Use when setting up data fetching, fixing v4→v5 migration errors (object syntax, gcTime, isPending, keepPreviousData), or debugging SSR/hydration issues with streaming server components.
accelint-nextjs-best-practices
IncludedNext.js performance optimization and best practices. Use when writing Next.js code (App Router or Pages Router); implementing Server Components, Server Actions, or API routes; optimizing RSC serialization, data fetching, or server-side rendering; reviewing Next.js code for performance issues; fixing authentication in Server Actions; or implementing Suspense boundaries, parallel data fetching, or request deduplication.