Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>JS Prompt AlertNew to Visual Studio Code? Get it now.
JS Prompt Alert

JS Prompt Alert

Jorin Eggers

|
464 installs
| (0) | Free
Add JavaScript prompt and alert to VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

VS Code WebSocket Extension

This extension allows you to open prompt and alert popups in VS Code using websockets.

Features

  • Show alert popup
  • Show prompt popup

Recommended Usage

Use together with the vscode-websocket-alerts package.

const { alert, prompt } = require('vscode-websocket-alerts');

let x = prompt('Enter a number');
alert(`You entered: ${x}`);

Manual Usage

  1. Install the extension.
  2. Connect to the WebSocket server:
    const WebSocket = require('ws');
    
    // Connect to the WebSocket server
    const ws = new WebSocket('ws://localhost:8121');
    
  3. Send a command when the connection is open:
    ws.on('open', () => {
        const alertMessage = { command: 'extension.showAlert', args: { message: 'Hello from Node.js!' } };
        ws.send(JSON.stringify(alertMessage));
    
        const promptMessage = {
            command: 'extension.showPrompt',
            args: {
                promptText: 'Please enter something:',
                callbackId: 1 // Assuming callback handling if needed
            }
        };
        ws.send(JSON.stringify(promptMessage));
    });
    
  4. Handle responses from the WebSocket server:
    ws.on('message', (data) => {
        const response = JSON.parse(data);
        console.log('Response from VS Code extension:', response);
    });
    
  5. Enjoy!
  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft