docs
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help
Getting Started
Tutorials
How-To Guides
Explanation
Reference
Help

Build and Test a WeChat/Weixin Mini Game

WeChat is also called Weixin in China. This guide uses “WeChat.”

Supported output

Needle creates a regular Mini Game project in dist/WeChat. The output includes the Needle WeChat platform adapter.

Mini Game Playable

The production Mini Game Playable is a different product. It has a separate AppID, API set, upload, and release process.

Requirements

  • A Mini Game test number or AppID
  • The current WeChat Developer Tools
  • Access to the AppID

Get a test number from the WeChat/Weixin sandbox.

1. Add the platform

import { defineConfig } from "vite";
import { loadConfig, needlePlugins } from "@needle-tools/engine/vite";

export default defineConfig(async ({ command }) => {
    const needleConfig = await loadConfig();
    return {
        plugins: [needlePlugins(command, needleConfig, {
            playableAds: {
                name: "MyGame",
                platforms: [{
                    platform: "wechat",
                    appId: "wx0000000000000000",
                    orientation: "portrait",
                }],
            },
        })],
    };
});

2. Build the project

npm run build -- --production

dist/WeChat contains these files:

  • game.js
  • game.json
  • project.config.json
  • Needle runtime files
  • Local game resources

AppSecret

Do not add the AppSecret to the project. Store the AppSecret on a trusted server.

3. Import the project

  1. Open WeChat Developer Tools.
  2. Select Mini Game.
  3. Import dist/WeChat.
  4. Enter the Mini Game AppID.
  5. Select Compile.

Import the folder that contains game.json. Do not select its parent folder.

4. Test in the simulator

  1. Check the scene, environment, textures, and UI.
  2. Start and finish the game.
  3. Test mouse input.
  4. Test touch input.
  5. Check that one touch creates one pointer.
  6. Test audio after the first interaction.
  7. Test particles and orientation.
  8. Hide and restore the game.
  9. Fix all red console errors.

5. Test on a device

  1. Select Preview in Developer Tools.
  2. Scan the QR code with WeChat/Weixin.
  3. Test on iOS.
  4. Test on Android.
  5. Record the Developer Tools version.
  6. Record the base-library version.
  7. Record the build hash, device, OS, and console output.

Test with an agent

Use an Electron agent or the WeChat IDE driver. Compile the project and record the console output.

Interact with the canvas. Capture a rendered frame. A successful compile message does not prove that the game renders.

Do not change the AppID or domain checks without permission. Do not upload a build without permission.

Run the Needle browser integration test before the Developer Tools test. The browser test covers files, rendering, input, lifecycle, audio, and startup.

Use a custom platform entry

Most projects do not need a custom entry. For a custom host action, install the adapter before the Engine import.

import { installWechatPlatform } from "@needle-tools/engine/playable/wechat";

export const wechatPlatform = installWechatPlatform({
    title: "My Game",
    open: () => {
        // Call an approved host action.
        return true;
    },
});

Use @needle-tools/engine/playable/wechat-context for custom Needle context creation.

See the WeChat target reference for all options.

Configure network access

The default playable build does not make network requests. For a networked Mini Game, add each required HTTPS or WSS domain.

Read the Mini Game network guide.

Prepare a production Mini Game Playable

Production access requires a verified enterprise Mini Game and the Playable capability.

  • Playable overview
  • Capability and release management
  • Development and API set

Check the AppID, package limits, game.json fields, wx APIs, device previews, upload, and review process.

Troubleshooting

ErrorAction
game.json is missingImport dist/WeChat. Re-import the folder after a rebuild.
Device rejects JavaScriptUpdate Needle. Build the WeChat output again.
Browser global is missingUpdate Needle. Remove each app-local platform shim.
Texture does not loadCheck the file below dist/WeChat. Use a package-relative path.
Scene is blackFind the first renderer or file-load error. Check rendered pixels.
One touch acts twiceRemove the app-local touch bridge. Use the Needle adapter.

See the Mini Game API types and the Tencent Mini Game tutorial.

Related pages

  • Test Playable Ads
  • Playable Ad Build Profiles
Suggest changes
Last Updated: 8/4/26, 2:47 PM

Extras

Needle AI Ask Needle AI
Copy Markdown

Navigation

  • Getting Started
  • Tutorials
  • How-To Guides
  • Explanation
  • Reference
  • Help

Extras

Needle AI Ask Needle AI
Copy Markdown