Migrates a React + TailwindCSS H5 web application to a native WeChat Mini Program...
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.
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.
The migration is a multi-step process that involves code transformation, style conversion, and API replacement. Follow these steps sequentially for a successful migration.
data and setData system.fetch, localStorage) with their WeChat Mini Program counterparts (wx.request, wx.setStorageSync).ls -R or tree command to inspect the source React project's directory structure. Identify the main components, pages, utility functions, and static assets.references/MIGRATION_MAP.md for the standard structure.app.js, app.json, and app.wxss root files.pages directory and subdirectories for each page identified in the React app.components directory for reusable components.utils directory for helper functions.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.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.
references/MIGRATION_MAP.md.div -> viewspan, p, h1-h6 -> textimg -> imagea -> navigatorbutton -> button.map() calls to wx:for loops.&&, ? : operators to wx:if, wx:elif, wx:else directives.{variable} to {{variable}}.onClick={handler} to bindtap="handler".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.
px or rem units to rpx. A common baseline is 1rem (16px) = 32rpx. Use this as a general rule but adjust for precision.*) or complex descendant selectors.gap Property: Since gap is not supported, implement spacing between flex/grid items using margin on the child elements..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.Page({...}) or Component({...}) object in the .js file.data object.useState declarations to initial values in the data object.setCount(1)) with this.setData({ count: 1 }).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.useEffect maps to onUnload.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' }).wx.switchTab for navigating to tab bar pages.wx.redirectTo for redirects.wx.navigateBack for going back.Replace all browser-specific APIs with their wx. counterparts.
fetch or axios with wx.request.localStorage with wx.setStorageSync and wx.getStorageSync.document.getElementById). Instead, use data binding to control the view./images). Update all <image> src paths to be absolute paths from the project root (e.g., /images/logo.png).wx.loadFontFace in app.js.references/MIGRATION_MAP.md: Contains detailed mapping tables for components, events, lifecycles, and APIs to assist in the conversion process.