Docs
Debug Your Mini Game
After you've developed your mini game and integrated Mini Games SDK to access TikTok capabilities, you can debug your mini game using DevTool, TikTok's mini game developer tool. Once you've completed debugging, you are ready to upload your code package to the Developer Portal.
Note: Before performing local debugging, please ensure that your mobile phone and computer are on the same network and can access the extranet environment normally.
Prerequisites
To complete the debugging process, you will need the following items and environments:
Required item | Description |
Access to Developer Platform | Run |
DevTool | Command-line interface tool for local development and debugging of TikTok mini games. You must install DevTool to debug your mini game. |
Exported game directory | When exporting your mini game code package from a third party game engine, choose a mainstream platform as the export type. TikTok native mini games are compatible with mainstream platforms, such as WeChat or Douyin. |
Google Chrome | DevTool provides a development and debugging environment based on the Google Chrome. Make sure Google Chrome is installed on the device you will use for debugging. |
NodeJS | DevTool is developed based on the NodeJS environment. Therefore, you must have NodeJS installed. Your Node version must not be lower than v20, otherwise you will encounter an error when trying to install DevTool. We recommend installing v20.19.5 or higher. |
Single wifi network | Local debugging on mobile phones and computers requires them to be on the same network. |
Test users | Local debugging can only be carried out after TikTok test users have been registered in the Testing permissions section of your app page. Otherwise, scanning the code will result in an error. |
TikTok Client | You must have the TikTok app installed on the device you will use for debugging. |
Trusted domains | Your domain name must be registered under your app's Development Configuration section. During runtime, mini-games can only initiate network requests to registered domains. Any domain not on the allowlist will be denied access. Therefore, all domains involved in network requests within mini games must be registered in advance. |
Install debug tool
To install TikTok's debug tool (DevTool), run the following command:
Note: You must use a Node.js environment. Check in advance if your Node version is >=20. If it is an earlier version, you must upgrade it before proceeding.
npm install @ttmg/cli -g --registry=https://registry.npmjs.org/
ttmg -v # Verify installationManage test users
Test users are TikTok accounts that you approve to debug and preview your app. Test users can also access the partial rollout version of your app, if you choose grey release.
If you plan to release your mini game to multiple global regions, we recommend having at least one TikTok test account per region.
Add test users to your app page in the Developer Portal:
- Go to the Testing permissions tab on your app page.
- Click the Add test users button.
- Connect the TikTok account that you want to add as a test user. You can add up to 30 test users per app.
- If you still get permission errors after adding test users, verify that the account is an adult account (minor accounts cannot be used for development testing)
Tip: If you click the Continue button when prompted to connect your TikTok account and nothing happens, you need to check whether your browser has blocked pop-ups. If so, you must allow pop-ups to add test users.
Complete local login
Functions provided by the debug tool, such as viewing game details and uploading the code package to the Developer Platform, require developers to log in to their TikTok for Developers account on the local endpoint before they can be used. We recommend that you complete the account login first and then proceed with subsequent debugging operations.
Log in to the CLI tool to access advanced features like code upload and project detail viewing:
ttmg loginConfigure trusted domains
All network requests from your mini game must go to domains registered in your app's allowlist:
- Go to your app settings in the Developer Portal.
- Navigate to the Development configuration page then go to the Security tab.
- Add all domains your game uses for API requests, resource downloads, and more.
Note: Any requests to unregistered domains will be blocked in both preview and production environments.
Debugging workflow
To debug your mini game, you will need to have completed code development and integration with TikTok's features.
Note: Before performing local debugging, please ensure that your mobile phone and computer are on the same network and can access the extranet environment normally.
Step 1: Export your game
TikTok mini games use a framework compatible with other mainstream mini game platforms:
- Export your game from your engine (such as Unity or Cocos) as a mini game project.
- The project structure is similar to mini games on Douyin or WeChat, with only minor API differences.
- Ensure your
game.jsonandproject.config.jsonfiles are properly configured.
Step 2: Initiate debugging session
Enter the game directory with the path to your game project:
cd path/to/your-game-projectThen start up the debugging environment. You will only be asked to enter your app's client key once, during the first debugging session. It will be stored for subsequent debugging sessions.
ttmg devBefore running your mini game's code exported by the game engine, TikTok will perform a compilation of the game artifact against its runtime framework. The mini game is then run based on this compiled artifact, ensuring consistent performance.
The compilation process will perform necessary pre-verification on the game atifact to help developers identify issues in advance. The verification includes the following:
game.jsonconfiguration: Is it configured? (Required)subpackagesingame.json: If present, is the configuration correct?mainfile: Does it exist, and is it correct?rootdirectory: Does it exist, and is it correct?- Game package size: Does it meet platform requirements? (This will show as a warning during local debugging, but will cause an error during platform deployment):
- The entire game package size cannot exceed 30 MB.
- The main game package size cannot exceed 4 MB.
- The size of an independent subpackage cannot exceed 4 MB.
Step 3: Select debug mode
There are two primary methods for testing and debugging your mini game: The debug mode type determines where the game's core logic is executed and how you access debugging tools.
Mode | Where logic runs | Description | Usage |
Mobile device | Game logic executes on the physical mobile device (TikTok app = Client). | Use the vConsole (an in-app, on-screen console) to view logs. This is the most authentic way to test visual and performance effects. | Best used when your local network condition is poor, as this mode is less reliant on continuous PC-to-browser communication. |
Remote browser | Game logic executes on the local PC browser (Chrome). | Allows advanced debugging (breakpoints, watching variables) using Chrome's DevTool. The mobile device synchronously mirrors the screen. | Best used when you need powerful, flexible breakpoint debugging and access to full browser development tools. |
Tip: If you require more flexibility, you can also create a new custom startup mode to meet specific debugging and preview requirements.
Step 4: Upload test version to Developer Portal
Upload your mini game to your app page on the Developer Portal via the DevTool. Unlike local debugging, this creates a persistent preview version hosted on TikTok's servers. All test users added to your app can access this version.
Note: Before scanning the code, confirm whether the current TikTok version supports native mini games. If unsupported, a 404 page will appear after scanning.
- Ensure you are logged in to the CLI (
ttmg login). - Click the Upload button in the DevTool web interface.
- After the package is successfully uploaded to the Developer Portal, go to the Code version tab on your app page.
- Find your uploaded mini game version under the Preview section.
Step 5: Scan the QR code to debug
- Click the Preview button next to your mini game version to generate a QR code.
- Scan the generated QR code with TikTok Client to preview the game.
- TikTok may require a VPN to be accessed normally.
- Before scanning the QR code, you need to log in using a test account.
- Wait for the TikTok app to verify whether the currently logged-in TikTok user has debugging permissions for this application.
- If authorized, the TikTok app will enable the debugging environment.
- If unauthorized, check the following:
- Open
project.config.jsonand check if theappidis consistent with the game ID on the Developer Portal. - Check whether the
appidinproject.config.jsonhas already added test users on the Developer Portal. - After completing debugging of user authentication, the debugging tool will start uploading the game package to TikTok app. After the upload is completed, it will start loading the game.
- The browser interface displays the upload progress, and after the upload is completed, the TikTok app starts the game.
- After the TikTok app completes the game startup, operate the game within the TikTok app and enter the module you want to debug.
- Use the browser Console to view your logged messages or debug your JavaScript.
- When you need to modify the code during debugging, you can select the same export path in the game engine export process.
- The local debugging service will monitor changes to the game's original code package and automatically perform pre-compilation.
- The debugging page will notify via a pop-up window after the modified code is compiled.
Advanced settings
You can modify debugging settings depending on the scenario you want to test.
- After enabling domain verification, only domains configured on the platform will be allowed to make requests.
- After enabling ad mock debugging, when calling JavaScript APIs for In-App Ads, it will enter the mock environment to help you debug various boundary scenarios.
- After enabling payment mock debugging, when calling JavaScript APIs for In-App Purchases, it will enter the mock environment to help you debug various boundary scenarios.
Set debug startup mode
During mini game development, internal logic is usually differentiated based on different traffic entry sources, and function customization can be achieved by selecting different scenario entry points.
If your mini game supports independent subpackages, you can also choose a specific subpackage as the code package at startup for debugging purposes.
Additionally, in scenarios related to advertising placement, developers often need to customize startup parameters for internal technical attribution within the game.
You can obtain these custom parameters by accessing the TTMinis.game.getLaunchOptionsSync method and use them in subsequent technical processes.
New startup mode
To configure a new startup mode:
- Select New launch mode from the dropdown above the QR code.
- Name your launch mode and select launch package and entry scene. Add custom launch parameters if needed.
- Click Save and apply.
Custom startup package
- Game main package startup: Load and start the game using the game entry file
game.js - Independent subpackage startup: Start, load, and debug the game using the independent subpackage entry file
Select to enter the scene
Simulate different traffic scenarios within the TikTok app to launch mini-games, enabling the development and debugging of subsequent processes
Add startup parameters
TTMinis.game.getLaunchOptionsSync method retrieves these custom parameters and uses them in subsequent technical processes.
// Get startup arguments
const launchOptions = TTMinis.game.getLaunchOptionsSync();
console.log('Startup scene value:', launchOptions.scene);
console.log('Startup query parameters:', launchOptions.query);
// Common usage example: Executing different logic based on startup parameters
if (launchOptions.scene === 'scan_qrcode') {
console.log('User enters the game by scanning a QR code');
}
if (launchOptions.query && launchOptions.query.from_user_id) {
console.log('The game was entered by a user sharing, sharer ID:', launchOptions.query.from_user_id);
}Development options
Information:
- After enabling domain name verification, only domain names configured on the platform will be allowed to make requests.
- After enabling ad mock debugging, when calling the ad JSAPI, it will enter the mock environment to help you debug various boundary scenarios.
- After enabling payment mock debugging, when calling the payment JSAPI, it will enter the mock environment to help you debug various boundary scenarios.
- Show vConsole, and you can view the running logs during preview on a real device
- Show the development information panel, where you can view game runtime statistics on your phone
Default development options
By default, development options allow you to choose either remote debugging or real device preview.
Domain name verification settings
By default, the requested domain name is verified and the Disable domain check toggle is switched off. When the domain name verification toggle is switched on, requests can be sent normally without registering a domain name on the Developer Platform.
Payment and ads development settings
You can toggle settings to test payment flows for In-App Purchases and In-App Ads:
- Enable IAP Mock: When switched on, making a payment will not require real money payment and the transaction will pass directly. When switched off, real money is required.
- Enable Ad Mock: Allows you to test configuration of In-App Ads.
Local code pre-check
Below is a list of what content to check:
- Package size check
- The size of the entire game package must be contained within 30 MB, the size of the main package cannot exceed 4 MB, and the size of independent subpackages cannot exceed 4 MB.
- Required connection capability check
- Check if the game has integrated the necessary API capabilities to ensure that the mini game has better user experience and conversion effects on TikTok.
- Configuration file check
game.json: Ensure that the configuration of the subpackage file paths is correct, all paths can be accessed normally, and avoid subsequent loading failures.project.config.json: Confirm that theappidhas been filled in and is a valid value; otherwise, local debugging will not run properly.
Explanation of package sizes
Note: Be aware of package size verification. During local development, failure to meet the requirements will only trigger an alert. During the upload to the platform, if the requirements are not met, the upload will fail.
Type | Restriction | Description |
Total project size | Source file size does not exceed 30 MB (before compression) | Size of the game project exported from the game engine |
Game main package size | The main package size does not exceed 4 MB (before compression) | All files in the game project, except those under |
Independent subpackage size | The main package size does not exceed 4 MB (before compression) | The size of the package body defined as |
Required capabilities
Required capabilities | Frontend interface | Reasons for mandatory connection |
User silent login |
|
|
Incentive ad video |
|
|
Home screen shortcut |
|
|
Open profile sidebar |
|
|
Configuration file instructions
Configuration file | Verification content | Post script |
| Is the subpackages configuration valid? | If the configured subpackage information is incorrect, an error will be reported directly, and the compilation process will be interrupted |
| Entry file of the game | -- |
| Does the | Under the local debugging environment, it has a strong dependency. If the configured |
Test the preview version
- On your app page in the Developer Portal, click the Code version tab.
- Find your uploaded mini game version in the Preview section. It should have been uploaded directly from the DevTool.
- Click the Preview button on your uploaded mini game to generate a QR code.
- Scan the QR code with a TikTok user account that you've already added as a test user.
Set development options
You can set development options while previewing your mini game on TikTok Client.
- Immediately after scanning the QR code, you will be directed to the mini game's loading page. On the loading page, tap the More options (...) button in the upper right corner of the screen.
- Tap Developer Options in the panel that appears.
- Turn on ShowDevInfo Panel and Show vConsole. This displays development info and a vConsole log.
Tip: If tapping the More options (...) button in the Client does not show Developer Options, long press the More options (...) button for 20-30 seconds. Then enter the More panel, and the Developer Options will appear.
Debug revisit features
Debugging user engagement and revisit features like home screen shortcut and revisit from profile require you to use New Startup Mode in DevTool.
Revisit from Profile incentive debugging
Test the profile sidebar reward functionality:
- Start debugging environment:
- Select New Startup Mode.
- Configure the startup mode as Sidebar Entry.
- Scan the QR code with TikTok to test the reward flow:
cd path/to/your/game
ttmg dev// Test sidebar reward claim
TTMinis.game.getEntranceMissionReward({
success: ({ canReceiveReward }) => {
console.log("success", canReceiveReward);
},
fail: () => {
console.log("fail");
},
complete: () => {
console.log("complete");
}
});Home Screen Shortcut incentive debugging
Test the desktop shortcut reward functionality:
- Start debugging environment:
- Select New Startup Mode.
- Configure the startup mode as Desktop Shortcut Entry.
- Scan the QR code with TikTok to test the reward flow:
cd path/to/your/game
ttmg dev// Test shortcut reward claim
TTMinis.game.getShortcutMissionReward({
success: ({ canReceiveReward }) => {
console.log("success", canReceiveReward);
},
fail: (error) => {
console.log("fail", error);
},
complete: () => {
console.log("complete");
}
});Upload local code to the Developer Portal
Once you have a version of your mini game that you're satisfied with, use DevTool to upload local game code packages to the Developer Portal for testing or debugging.
This feature allows you to directly select the code package to be uploaded and push it to the Developer Portal after completing code writing and packaging locally.
This process helps you quickly verify the content of different versions or sub-packages, enhancing the flexibility of development and debugging.
Troubleshooting
Permission isues
I get "no permission" error when scanning the QR code Verify the following:
- Your TikTok account is added as a test user in the Developer Portal
- You are using an adult TikTok account (minor accounts are restricted)
- The Client Key in your project configuration matches the app in the Developer Portal
Network issues
Network requests are being blocked Check the following:
- All domains your game uses are added to the trusted domains list in the Developer Portal
- Your requests use HTTPS protocol (HTTP requests are blocked)
- WebSocket URLs don't include port numbers
- Resource file paths don't contain spaces
Debugging settings
I can't find the developer options in the TikTok app When scanning a preview QR code:
- Tap the three dots (...) in the top right corner during loading
- If no menu appears, long press the three dots for 20-30 seconds to reveal the developer options
- From here you can enable vConsole, show development info, and access other debugging features
Performance issues
The game is laggy or dropping frames
- For remote debugging lag: This is normal due to network transmission; switch to real device preview for accurate performance testing
- For real device lag: Optimize your game's performance (reduce draw calls, optimize assets, etc.)
- Persistent performance issues should be reported to the platform team for investigation
Online version troubleshooting
For issues in production versions:
- Open the game in TikTok
- Long press the three dots (...) in the top right corner for 20-30 seconds to reveal the developer options
- Turn on ShowDevInfo Panel to view version information and runtime statistics
Note: Online versions have limited debugging capabilities. Log viewing and function simulation are not available, only the development info overlay is accessible.
Next step: Release your mini game
After debugging your code, you are ready to upload, preview, submit for review, and release to users.