react-to-wx-miniprogram-migrator
Migrates a React + TailwindCSS H5 web application to a native WeChat Mini Program. Use when the user wants to convert their existing web project into a mini program, preserving structure, styling, and functionality.
Best use case
react-to-wx-miniprogram-migrator is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Migrates a React + TailwindCSS H5 web application to a native WeChat Mini Program. Use when the user wants to convert their existing web project into a mini program, preserving structure, styling, and functionality.
Teams using react-to-wx-miniprogram-migrator should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/react-to-wx-miniprogram-migrator/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How react-to-wx-miniprogram-migrator Compares
| Feature / Agent | react-to-wx-miniprogram-migrator | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Migrates a React + TailwindCSS H5 web application to a native WeChat Mini Program. Use when the user wants to convert their existing web project into a mini program, preserving structure, styling, and functionality.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# React + TailwindCSS to WeChat Mini Program Migration Skill
This skill provides a systematic process for an AI agent to migrate a web application built with React and TailwindCSS into a native WeChat Mini Program. The goal is to achieve a functional and stylistically faithful conversion by mapping modern web development patterns to the specific architecture of WeChat Mini Programs.
## When to Use This Skill
Use this skill when the user explicitly requests to convert a React-based H5 website, especially one using TailwindCSS for styling, into a native WeChat Mini Program. The source code of the React project should be available for analysis.
## Migration Process Overview
The migration is a multi-step process that involves code transformation, style conversion, and API replacement. Follow these steps sequentially for a successful migration.
1. **Analyze Source & Setup Project**: Analyze the React project structure and set up a corresponding WeChat Mini Program project.
2. **Component & JSX to WXML Conversion**: Convert React components and JSX syntax into Mini Program components and WXML structure.
3. **TailwindCSS to WXSS Conversion**: Transform TailwindCSS utility classes into equivalent WXSS styles.
4. **Logic & State Management Migration**: Adapt React's state management (Hooks, Redux) and lifecycle to the Mini Program's `data` and `setData` system.
5. **Routing & Navigation Replacement**: Replace web-based routing (e.g., React Router) with the Mini Program's page navigation API.
6. **API & SDK Replacement**: Substitute browser/web APIs (e.g., `fetch`, `localStorage`) with their WeChat Mini Program counterparts (`wx.request`, `wx.setStorageSync`).
7. **Asset & Resource Handling**: Migrate and correctly reference static assets like images and fonts.
8. **Final Review & Debugging**: Thoroughly test the migrated application in the WeChat DevTools and on a physical device.
---
## Step-by-Step Migration Instructions
### Step 1: Analyze Source & Setup Project
1. **Analyze React Project**: Use the `ls -R` or `tree` command to inspect the source React project's directory structure. Identify the main components, pages, utility functions, and static assets.
2. **Create Mini Program Structure**: Based on the analysis, create a standard WeChat Mini Program directory structure. Refer to `references/MIGRATION_MAP.md` for the standard structure.
- Create the `app.js`, `app.json`, and `app.wxss` root files.
- Create a `pages` directory and subdirectories for each page identified in the React app.
- Create a `components` directory for reusable components.
- Create a `utils` directory for helper functions.
3. **Configure `app.json`**: Populate the `app.json` file. List all the pages in the `pages` field. If the H5 app has a tab bar, configure the `tabBar` field accordingly.
### Step 2: Component & JSX to WXML Conversion
This is the core of the UI migration. Convert each React component into a Mini Program component folder containing `.js`, `.wxml`, `.wxss`, and `.json` files.
1. **Map HTML Tags to WXML Components**: For each JSX file, systematically replace HTML tags with their corresponding WXML component equivalents. A detailed mapping can be found in `references/MIGRATION_MAP.md`.
- `div` -> `view`
- `span`, `p`, `h1`-`h6` -> `text`
- `img` -> `image`
- `a` -> `navigator`
- `button` -> `button`
2. **Convert JSX Syntax**: Transform JSX control flow and expressions into WXML directives.
- **List Rendering**: Convert `.map()` calls to `wx:for` loops.
- **Conditional Rendering**: Convert `&&`, `? :` operators to `wx:if`, `wx:elif`, `wx:else` directives.
- **Data Binding**: Convert `{variable}` to `{{variable}}`.
- **Event Handling**: Convert `onClick={handler}` to `bindtap="handler"`.
### Step 3: TailwindCSS to WXSS Conversion
This is a critical and potentially complex step. The primary challenge is converting utility-first CSS into static WXSS stylesheets, as Mini Programs do not have a JIT compiler for styles.
1. **Identify All Tailwind Classes**: Scan all JSX files and extract every TailwindCSS class name used.
2. **Convert Classes to CSS**: Use an online tool or a script to convert the list of Tailwind classes into standard CSS. You can use this [Tailwind to CSS Converter](https://tailwind-to-css.vercel.app/) for this purpose.
3. **Adapt CSS for WXSS**: Manually adjust the generated CSS to be compatible with WXSS.
- **Convert Units**: Change `px` or `rem` units to `rpx`. A common baseline is `1rem` (16px) = `32rpx`. Use this as a general rule but adjust for precision.
- **Handle Unsupported Selectors**: Replace unsupported selectors like the universal selector (`*`) or complex descendant selectors.
- **Address `gap` Property**: Since `gap` is not supported, implement spacing between flex/grid items using `margin` on the child elements.
4. **Organize Styles**: Paste the converted styles into the appropriate `.wxss` files. Global styles (from `index.css` or `App.css`) go into `app.wxss`, and component-specific styles go into the component's `.wxss` file.
### Step 4: Logic & State Management Migration
1. **Component Logic**: Move the logic from the React component function body into the `Page({...})` or `Component({...})` object in the `.js` file.
2. **State Management**: Refactor React state to the Mini Program's `data` object.
- Convert `useState` declarations to initial values in the `data` object.
- Replace state update calls (e.g., `setCount(1)`) with `this.setData({ count: 1 })`.
3. **Lifecycle Methods**: Map React's lifecycle hooks to Mini Program lifecycle methods. See `references/MIGRATION_MAP.md` for a detailed mapping.
- `useEffect` with an empty dependency array `[]` maps to `onLoad`.
- `useEffect` with no dependency array maps roughly to `onShow`.
- The return function from `useEffect` maps to `onUnload`.
### Step 5: Routing & Navigation Replacement
Replace all instances of React Router or other routing libraries with the Mini Program's built-in navigation API.
- `<Link to="/path">` or `navigate('/path')` becomes `wx.navigateTo({ url: '/pages/path/index' })`.
- Use `wx.switchTab` for navigating to tab bar pages.
- Use `wx.redirectTo` for redirects.
- Use `wx.navigateBack` for going back.
### Step 6: API & SDK Replacement
Replace all browser-specific APIs with their `wx.` counterparts.
- **Network Requests**: Replace `fetch` or `axios` with `wx.request`.
- **Local Storage**: Replace `localStorage` with `wx.setStorageSync` and `wx.getStorageSync`.
- **DOM Manipulation**: Remove all direct DOM manipulation code (e.g., `document.getElementById`). Instead, use data binding to control the view.
### Step 7: Asset & Resource Handling
1. **Images**: Move all image assets into a dedicated directory (e.g., `/images`). Update all `<image>` `src` paths to be absolute paths from the project root (e.g., `/images/logo.png`).
2. **Fonts**: If custom fonts are used, they need to be loaded using `wx.loadFontFace` in `app.js`.
### Step 8: Final Review & Debugging
1. **Use WeChat DevTools**: This is your primary environment for testing and debugging. Check the console for errors and use the WXML panel to inspect the UI structure.
2. **Test on Device**: Preview the Mini Program on a physical device to check for performance issues and styling inconsistencies that may not appear in the simulator.
3. **Iterate and Refine**: The migration process is iterative. Expect to go back and forth between steps to fix bugs and refine the user experience.
---
## Bundled Resources
- **`references/MIGRATION_MAP.md`**: Contains detailed mapping tables for components, events, lifecycles, and APIs to assist in the conversion process.Related Skills
react
Full React 19 engineering, architecture, Server Components, hooks, Zustand, TanStack Query, forms, performance, testing, production deploy.
react-ui-patterns
Modern React UI patterns for loading states, error handling, and data fetching. Use when building UI components, handling async data, or managing UI states.
react-synapse
A React state management library using Preact Signals with fine-grained reactivity. Use it when you need global state without providers, minimal re-renders, or immutable updates via draft mutations. Works with React 18+.
react-patterns
Modern React patterns and principles. Hooks, composition, performance, TypeScript best practices.
react-observability
Logging, error messages, and debugging patterns for React. Use when adding logging, designing error messages, debugging production issues, or improving code observability. Works for both React web and React Native.
react-nextjs-development
React and Next.js 14+ application development with App Router, Server Components, TypeScript, Tailwind CSS, and modern frontend patterns.
react-native-architecture
Build production React Native apps with Expo, navigation, native modules, offline sync, and cross-platform patterns. Use when developing mobile apps, implementing native integrations, or architecti...
react-modernization
Upgrade React applications to latest versions, migrate from class components to hooks, and adopt concurrent features. Use when modernizing React codebases, migrating to React Hooks, or upgrading to...
react-guidelines
React coding guidelines and best practices. MUST follow these rules. Use when reviewing or writing React code or tasks.
react-gradual-architecture
Incremental React code organization guidelines. Start small, then extract when scanning and responsibilities start to blur. Use when creating features, organizing files, refactoring components, or deciding when to extract hooks, UI, or utils.
react-grab
Installs and configures React Grab for visual UI element selection in React/Electron apps. Use when user wants to edit UI visually, select components by hovering, or capture element context.
react-frontend
React components for Chat, Evaluation, Report, Admin with TypeScript, Tailwind, hooks