Configure

SDK runtime management

Choose a Mimic runtime version, prepare an offline installation, share the cache across languages, and control process ownership and timeouts.

On this page

SDK documentation / Runtime management

Call launch to download the selected Mimic release when needed, start it headless and connect your client. Call connect when a runtime is already running. You do not need to find an executable or install Chromium.

Start with the language and client setup for installation from the SDK's GitHub release.

Choose an exact version

Every SDK package carries a default runtime lock. A no-argument launch uses that pinned release, so a newly published Mimic runtime does not silently change an existing application. SDK package versions and Mimic runtime versions are independent. Updating the SDK may update its default pin; use an explicit runtime version or lock to keep your application on the same one.

Acceptable selectors are exact versions such as 0.2.4,v0.2.4 or an exact beta release. Ranges, latest and wildcard selectors are rejected. An explicit version and lock must agree.

  1. An explicit runtime version or runtime lock selects the release.
  2. Otherwise, MIMIC_RUNTIME_VERSION selects it.
  3. Otherwise, the SDK's packaged default lock selects it.

Selecting another release resolves its manifest from that exact official GitHub release. The SDK verifies the manifest checksum, archive length and checksum, executable checksum and release identity. A saved runtime lock also retains the release's source provenance. Keep it intact instead of assembling one by hand.

One persistent cache across languages

PlatformDefault runtime directory
Windows amd64%LOCALAPPDATA%\Mimic\runtimes
Linux amd64$XDG_CACHE_HOME/Mimic/runtimes, or ~/.cache/Mimic/runtimes

All SDKs reuse this layout. Each release/platform/binary hash has its own installation, so several versions can coexist and concurrent installs do not replace an executable another process is using. Set MIMIC_RUNTIME_DIR or the corresponding language option to choose another root. An explicit option takes precedence over the environment variable.

Cached files are verified before reuse. Installation happens in a temporary staging directory and becomes visible only when complete. The cache must be writable and support atomic filesystem operations; keep it on local storage when sharing it between applications on the same machine. Runtime installation locks do not serialize your browser contexts or pages.

Local auto-install supports Windows amd64 and Linux amd64 with glibc 2.39 or newer. Linux also needs the release's system libraries and fonts; see platform requirements. macOS, ARM64 and musl-based Linux do not have packaged runtime artifacts. Connecting to an already-running runtime does not perform local platform installation checks.

Prepare once, then run without downloads

Installation is explicit when you need it to be: call the runtime manager's install method during setup, then launch with downloads disabled. Importing the SDK, creating a manager and connecting to a running runtime never download or start a browser.

These complete examples use the Playwright client from the setup guide. Run the first preparation step while online; deployment can retain only the offline launch section once the same cache is available.

offline.mjs · run with node offline.mjs
import { RuntimeManager } from "mimic-browser";
import { launch } from "mimic-browser/playwright";

const options = { runtimeVersion: "0.2.4", timeout: 60_000 };

// Prepare once while downloads are allowed. This does not start a browser.
const executable = await new RuntimeManager(options).install();
console.log(executable);

// Reuse the verified installation without any installer network requests.
const session = await launch({ ...options, allowDownload: false });
try {
  const context = await session.newContext();
  const page = await context.newPage();
  await page.setContent("<title>Offline runtime</title><h1>Ready</h1>");
  console.log(await page.title());
} finally {
  await session.close();
}
offline.py · run with python offline.py
from mimic import RuntimeManager
from mimic.playwright.sync_api import launch

options = {"runtime_version": "0.2.4", "timeout": 60}

# Prepare once while downloads are allowed. This does not start a browser.
executable = RuntimeManager(**options).install()
print(executable)

# Reuse the verified installation without any installer network requests.
with launch(**options, allow_download=False) as session:
    context = session.new_context()
    page = context.new_page()
    page.set_content("<title>Offline runtime</title><h1>Ready</h1>")
    print(page.title())

MIMIC_DOWNLOAD=0 disables installer network requests. A missing installation or uncached manifest fails explicitly. It does not disable network access from pages: configure browser networking separately. For a portable environment policy, leave the explicit download option unset; .NET, Java/Kotlin and PHP always honor MIMIC_DOWNLOAD=0, while the other SDKs let an explicitly supplied download option override it.

Install an official archive on an air-gapped machine

Save the selected lock while online and copy it together with the matching official platform archive to the destination. A custom version needs its manifest too; copying only an executable into the cache is insufficient. The installer still verifies the archive and extracted binary when downloads are disabled.

save-lock.mjs · run with node save-lock.mjs
import { writeFile } from "node:fs/promises";
import { RuntimeManager } from "mimic-browser";

const manager = new RuntimeManager({ runtimeVersion: "0.2.4" });
const lock = await manager.resolveLock();
await writeFile("mimic-runtime.lock.json", JSON.stringify(lock, null, 2) + "\n");
console.log("Saved mimic-runtime.lock.json");
install-archive.mjs
import { readFile } from "node:fs/promises";
import { RuntimeManager } from "mimic-browser";

// Pass the official archive filename as the first command-line argument.
const archivePath = process.argv[2];
if (!archivePath) throw new Error("Supply the downloaded Mimic archive filename");
const lock = JSON.parse(await readFile("mimic-runtime.lock.json", "utf8"));
const executable = await new RuntimeManager({ lock, allowDownload: false })
  .install({ archivePath });
console.log(executable);

Place both files in your project directory. On Linux run node install-archive.mjs mimic-v0.2.4-linux-amd64.tar.gz; on Windows use mimic-v0.2.4-windows-amd64.zip instead.

LanguageInstall without starting a browser
JavaScript / TypeScriptnew RuntimeManager(options).install({ archivePath, signal })
PythonRuntimeManager(**options).install(archive_path=filename)
C# / .NETnew RuntimeManager().InstallAsync(options, cancellationToken); options.ArchivePath
Java / Kotlinnew RuntimeManager().install(options); options.archivePath
Gomimic.NewRuntimeManager(options).Install(ctx); options.ArchivePath
RustRuntimeManager::new(options)?.install().await?; options.archive_path
RubyMimicSDK::RuntimeManager.new(**options).install; archive_path: filename
PHP(new RuntimeManager())->install($options); $options->archivePath

Use an executable you provide

Supply an executable option or MIMIC_EXECUTABLE_PATH for a local build or a runtime managed by your deployment. The explicit option wins over the environment variable, then the verified cache is the fallback. A missing or invalid explicit executable is an error; it does not trigger a download of a different binary.

An explicit version still checks the running Mimic version. An explicit lock additionally checks the executable hash before starting it. With an explicit executable and no explicit version, lock or version environment variable, local development builds can run without pretending to be the packaged default release. The SDK still verifies that it connected to Mimic.

Close what your session owns

How you connectWhat closing the session does
launchCloses helper-created contexts, disconnects the client and shuts down the owned Mimic process.
connectCloses helper-created contexts and disconnects. The runtime and other clients remain running.

Launch always starts headless on a dynamically assigned loopback port. Use the session's actual endpoint when passing the runtime to another client; do not assume a fixed port. Connect accepts an HTTP(S) discovery endpoint or browser WS(S) endpoint and checks Mimic identity. It never installs or starts a local process.

Use try/finally, a context manager or your language's disposal construct. Startup failures, attachment failures and supported cancellation paths clean up an owned child. Parent-death behavior depends on the runtime release; explicit session closure is the portable guarantee. The original v0.2.2 Linux runtime does not have the later Unix parent-death watcher.

The SDK retains genuine framework browser, context and page objects. A Playwright driver passed into an integration is borrowed and is not stopped on session close. See contexts and profiles for context ownership and camera and microphone for capture lifetime.

Option names by language

JavaScript/TypeScript and Python accept runtime options directly on launch and on RuntimeManager. Ruby uses keyword arguments. .NET, Java/Kotlin, Go, Rust and PHP use their RuntimeOptions type. Java exposes fields and fluent setters; Kotlin uses the same Java API.

Version, cache and executable options in every language
LanguageVersionLockExecutableCacheDownloads
JavaScript / TypeScriptruntimeVersionlock (object)executablePathruntimeDirallowDownload
Pythonruntime_versionlock (dict or filename)executable_pathruntime_dirallow_download
C# / .NETVersionLockFileExecutablePathRuntimeDirectoryAllowDownload
Java / KotlinversionlockFileexecutablePathruntimeDirectoryallowDownload
GoVersionLockFileExecutablePathRuntimeDirAllowDownload (*bool)
Rustversionlock_fileexecutable_pathruntime_dirallow_download (Option<bool>)
Rubyruntime_versionlock_fileexecutable_pathruntime_dirallow_download
PHPversionlockFileexecutablePathruntimeDirectoryallowDownload

Node's framework option passes connection options to the selected native client. Context emulation belongs in context options, not runtime options. Node and Python expose engine, defaulting to v8; changing it does not imply equal compatibility. .NET, Java/Kotlin and PHP expose Arguments/arguments for extra runtime CLI arguments and reject attempts to override headless mode or the listener.

Downloads, browser proxies and timeouts

Installer traffic fetches official release metadata and archives. A browser context proxy controls page requests and does not proxy these downloads. Configure the native HTTP stack used by your SDK before creating the manager; there is no shared SDK downloadProxy option.

Proxy and certificate configuration by language
SDKInstaller network configuration
NodeUndici's environment proxy agent uses HTTP_PROXY, HTTPS_PROXY and NO_PROXY. Additional trust can be supplied through Node's NODE_EXTRA_CA_CERTS before process startup.
Pythonurllib uses its proxy discovery and the Python/OpenSSL trust configuration.
.NETHttpClient uses the platform proxy and certificate trust configuration.
Java / KotlinJDK HttpClient uses its default ProxySelector and JVM trust store; do not assume shell proxy variables configure the JVM.
GoThe default net/http transport uses environment proxy settings. Set RuntimeManager.HTTPClient for a custom transport, certificate policy or request limit.
Rustreqwest's default proxy and TLS configuration; no per-manager HTTP client override is exposed.
RubyURI proxy discovery and Net::HTTP/OpenSSL trust configuration.
PHPlibcurl proxy and certificate configuration.

Runtime preparation, process startup and page navigation are separate waits. The values below are runtime-manager defaults, not one end-to-end deadline. Set navigation or selector timeouts through your framework's usual API.

Timeout defaults, units and cancellation
LanguageDefault optionsScope and cancellation
JavaScript / TypeScripttimeout: 60_000The same millisecond value bounds each download, install-lock wait and runtime startup. signal accepts an AbortSignal on launch/connect and manager install/launch/resolveLock.
Pythontimeout=60Seconds for installer socket operations, install-lock wait and startup. Async launch handles task cancellation by waiting for ownership acquisition and cleaning up; synchronous installation has no cancellation token.
C# / .NETTimeout: 60 s; LockTimeout: 120 sTimeSpan values. Timeout bounds startup; installer HTTP timeout is 3 minutes. Async operations accept CancellationToken.
Java / Kotlintimeout: 60 s; lockTimeout: 120 sDuration values. timeout bounds startup; HTTP requests use 3 minutes and connection establishment uses 30 seconds. Blocking operations observe thread interruption.
GoStartupTimeout: 30 s; LockTimeout: 120 stime.Duration values; zero selects these defaults. Methods take context.Context. RuntimeManager.HTTPClient can customize the installer; its default request timeout is 2 minutes.
Ruststartup_timeout: 30 s; lock_timeout: 60 sstd::time::Duration values. Installer HTTP timeout is 2 minutes. Cancel async work through the future/task; explicitly await session.close() for orderly teardown.
Rubystartup_timeout: 30 s; lock_timeout: 120 sNumeric seconds. cancelled accepts a callable checked during installation and startup. HTTP uses a 20-second connection timeout and 120-second read timeout.
PHPtimeout: 60 s; lockTimeout: 120 sNumeric seconds. timeout bounds startup. Downloads use a 20-second connection timeout and 120-second total timeout. There is no installer cancellation token.

Node connect(endpoint, { timeout, signal, framework }) uses milliseconds for its SDK transport timeout; connection options inside framework retain their native meanings. Python connect(endpoint, timeout=30) uses seconds. Python launch's manager timeout does not change its separate 30-second framework attachment timeout. Cancellation can wait for native cleanup; it is not an instruction to abandon a process still being acquired.

Resolve setup failures

FailureNext step
Unsupported platform or libcUse a supported runtime host and connect to it, or use the supported Windows/Linux amd64 environment.
Missing runtime while offlinePrepare the same release and platform in the selected cache, including its manifest, or supply the matching official archive and lock.
Integrity or conflicting provenanceCheck that the archive, lock and selected release match. Do not edit checksums or reuse a release name for different bytes.
Installation lock timeoutCheck the owner recorded under the cache's .locks directory. Do not delete a live or unknown owner's lock. Repair a crashed install only after confirming the same-host owner process is gone.
Startup or attachment failureRead the SDK's captured child output and reported endpoint/identity error. Check system libraries, executable permissions and the selected native client.
Runtime removed while in useStop applications using it before cache maintenance. Retain live or unverifiable lease records; deleting cache directories is not a shutdown mechanism.

Continue with contexts and profiles,media devices or the launch and connect examples.