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

Playable Ad Build Profiles

Package entry points

ImportContents
@needle-tools/engine/viteBuild profiles and WeChat packaging
@needle-tools/engine/playablePlayable lifecycle, audio, viewability, and CTA bridge
@needle-tools/engine/playable/wechatWeChat platform adapter
@needle-tools/engine/playable/wechat-contextCustom WeChat Needle context creation

Import playable and WeChat APIs from the entry points in this table.

High-level project setting

Add playableAds to the needlePlugins() settings:

type NeedlePlayableAdsOptions = {
    name?: string;
    appStoreUrls?: {
        ios?: string;
        android?: string;
    };
    platforms: NeedlePlayableAdTarget[];
    build?: {
        useRapier?: boolean;
        usePostprocessing?: boolean;
        noPeer?: boolean;
        excludeOptionalModules?: string[];
    };
};

Add at least one platform. The build stops for a duplicate or unknown platform.

Platform entries

platformAdditional fieldsDefault output
applovinShared playable optionsdist/AppLovin/index.html
unityShared options; optional legacy appleAppStoreUrl, googlePlayStoreUrldist/UnityAds/index.html
tiktokorientation, archiveNamedist/TikTok/playable.zip
google-adsorientation, archiveNamedist/GoogleAds/playable.zip
metaarchiveNamedist/Meta/playable.zip
mintegralname, actionPointsdist/Mintegral/<name>.zip
wechatWeChat options; appId requireddist/WeChat/

Unity requires at least one iOS or Android store destination. WeChat requires an AppID.

Opt-in behavior

Only the platforms array selects outputs. Store URLs and project names do not select outputs.

Build helpers

Import these helpers from @needle-tools/engine/vite.

HelperReturn value / purpose
createPlayableAdsSettings(options)Converts playableAds options to Needle plugin settings
needleSingleHtml(options)Low-level, platform-neutral single-HTML Vite plugin
playableAd(options)Shared offline playable settings and bridge
appLovinPlayableAd(options)AppLovin profile
unityPlayableAd(options)Unity Ads profile
tiktokPlayableAd(options)TikTok profile
googleAdsPlayableAd(options)Google Ads profile
metaPlayableAd(options)Meta profile
mintegralPlayableAd(options)Mintegral profile
playableAds(profiles, options)Creates several HTML or ZIP outputs from one browser build
wechatMiniGame(options)Creates a separate WeChat Mini Game Vite target
packageBuildAsSingleHtml(directory, options)Packages an existing build directory
packageBuildAsSingleHtmlProfiles(directory, profiles)Packages several outputs from an existing build directory

License requirement

Playable profiles require a commercial Needle license for output without Needle branding. needleSingleHtml() is the low-level single-file helper.

Shared playable options

OptionTypeDefault
outputDirectorystringrequired for multi-profile output
maxBytesnumber5_000_000
reportPathstringprofile-specific path below .needle/playables
appStoreUrls{ ios?: string; android?: string }none
mraidbooleantrue
failOnExternalUrlsbooleanprofile-specific
strictResourceEncodingbooleantrue
stripRemoteRuntimeFeaturesbooleantrue
stripExternalUrlLiteralsbooleanprofile-specific
disallowWindowTopbooleanprofile-specific
offlineRuntimebooleantrue
webglFallbackboolean | { title?: string; message?: string }true
excludeOptionalModulesstring[][]
singleHtmlboolean | NeedleSingleHtmlOptionsenabled
makeFilesLocalNeedle localization optionsenabled with playable exclusions

Platform options

TikTok

OptionValuesDefault
orientation0 responsive, 1 portrait, 2 landscape0
archiveNameZIP filename without directoriesplayable.zip

Google Ads

OptionValuesDefault
orientationportrait, landscape, portrait,landscapeportrait,landscape
archiveNameZIP filename without directoriesplayable.zip

Meta

OptionValuesDefault
archiveNameZIP filename without directoriesplayable.zip

The ZIP contains one self-contained root index.html. The profile rejects invalid names, redirects, external game URLs, and files above 5 MB.

The profile also rejects browser popups and XMLHttpRequest.

Mintegral

OptionTypeConstraint
namestringletters, numbers, and underscores only
actionPointsstring[]up to five non-empty descriptions

The Mintegral ZIP, folder, and HTML file use name.

Runtime bridge

import { bindPlayableAd, getPlayableAd } from "@needle-tools/engine/playable";

getPlayableAd() returns the active platform API. bindPlayableAd(context) connects pause and audio state to the Needle context.

Common members:

MemberPurpose
readyResolves when the host bridge is ready
start()Starts the playable timer after user interaction
open()Calls the platform CTA
notifyReady()Signals that required content is ready
notifyEnd()Signals win/failure or the end of play
notifyRetry()Signals a retry
track(id)Reports a platform action point when supported
on(type, listener)Subscribes to bridge events
elapsedTimeActive playable time in seconds
isPaused, muted, volumeCurrent host lifecycle/audio state

Call start() from the first game interaction. Call open() only from an explicit CTA.

Mintegral lifecycle

NeedlePlayturbo/Mindworks
notifyReady()window.gameReady()
host startglobal gameStart() emits Needle start
notifyEnd()window.gameEnd()
notifyRetry()window.gameRetry()
host closeglobal gameClose() pauses and mutes Needle
open()window.install()

Compliance report

Playable build reports include:

  • output path, upload size, HTML size, and limit;
  • output and source-build SHA-256 hashes;
  • embedded files and bytes by MIME type;
  • Base64 encoded, decoded, and expansion bytes;
  • external application URLs and intentional platform URLs;
  • resource-encoding findings;
  • platform, orientation, ZIP settings, and compatibility settings.

The report describes the build. Run the platform validator before upload.

WeChat/Weixin Mini Game target

wechatMiniGame(options) creates a WeChat Vite target without HTML.

OptionType / meaning
appIdRequired Mini Game AppID; never an AppSecret
htmlEntryRegular Needle HTML entry used to derive platform, host, and game entries
platformEntryAdvanced custom platform entry; requires gameEntry
gameEntryAdvanced custom application entry; requires platformEntry
orientationportrait or landscape
outputDirectoryDeveloper Tools project; default dist/WeChat
stagingDirectoryTemporary Vite output
assetsDirectoryApplication assets copied below the package assets folder
prepareAssetsOptional post-copy asset hook
requiredAssetsPackage-relative files required by validation
requiredRuntimeTokensRuntime capabilities required by validation
excludeOptionalModulesModule IDs replaced for this target
useRapierInclude Rapier; capability-driven when omitted
usePostprocessingInclude post-processing; capability-driven when omitted
maxJavaScriptBytesPer-file parser budget; default 2,048,000 bytes
maxPackageBytesOptional package budget
originLocal import.meta origin
urlCheckDeveloper Tools production domain/TLS checking; default true

Generated files include game.js, game.json, project.config.json, platform/host/game entries, CommonJS chunks, assets, and a build report.

Install the public adapter before the Engine import:

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

Import createWechatPlatformContext() from @needle-tools/engine/playable/wechat-context.

Related

  • Build Playable Ads
  • Test Playable Ads
  • How Playable Ads Work
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