Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

@wp-playground/client

Package Overview
Dependencies
Maintainers
5
Versions
181
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wp-playground/client

WordPress Playground client

latest
Source
npmnpm
Version
3.0.8
Version published
Weekly downloads
4.1K
-27.27%
Maintainers
5
Weekly downloads
 
Created
Source

Playground Client

Provides a PlaygroundClient that can be used to control a WordPress Playground iframe:

import { startPlaygroundWeb } from '@wp-playground/client';

const client = await startPlaygroundWeb({
	// An iframe pointing to https://playground.wordpress.net/remote.html:
	iframe: document.getElementById('wp'),
	remoteUrl: `https://playground.wordpress.net/remote.html`,
});

const response = await client.run({
	// wp-load.php is only required if you want to interact with WordPress.
	code: '<?php require_once "/wordpress/wp-load.php"; $posts = get_posts(); echo "Post Title: " . $posts[0]->post_title;',
});
console.log(response.text);

Using TypeScript is highly recommended as this package ships with comprehensive types – hit ctrl+space in your IDE after client. and you'll see all the available methods.

Once you have a PlaygroundClient instance, you can use it to control the playground:

await client.writeFile('/index.php', '<?php echo "Hi!"; ');
await client.run({
	scriptPath: '/index.php',
});

console.log(await client.readFileAsText('/index.php'));

await client.request({
	url: '/index.php',
	method: 'POST',
	body: {
		foo: 'bar',
	},
});

To see all the available methods, check out the PlaygroundClient interface.

FAQs

Package last updated on 02 Oct 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts