Vue Ray Debugger

2.0.3 · active · verified Tue Apr 21

vue-ray is a utility designed for debugging Vue 3 applications by sending debugging information to the desktop Ray app. Currently at version 2.0.3, the package maintains an active release cadence, with notable updates including a major rewrite in v2.0.1. This rewrite transitioned the package to an ESM-first architecture and removed support for Vue 2 and Node.js versions below 18. It offers two primary integration methods: a global `RayPlugin` for application-wide configuration and a `raySetup()` composable for `<script setup>` contexts. The package's key differentiator is its seamless integration with the commercial Ray debugging application, providing a dedicated GUI for inspecting data, component lifecycle events, and errors, offering a richer debugging experience than traditional `console.log` methods.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates both global `RayPlugin` installation for app-wide settings and component-level `raySetup()` usage in a `<script setup>` component to send data, lifecycle events, and interactive messages to the Ray desktop debugger.

import { createApp, ref, onMounted } from 'vue';
import App from './App.vue';
import { RayPlugin, raySetup } from 'vue-ray';

// main.ts or main.js
const app = createApp(App);

app.use(RayPlugin, {
    port: 23517, // Default Ray app port
    host: 'localhost',
    interceptErrors: true, // Send Vue errors to Ray
    nodeRaySettings: {
        interceptConsoleLog: true // Also send console.log messages to Ray
    }
});

app.mount('#app');

// src/components/MyComponent.vue (using <script setup>)
<template>
  <div>
    <h1>{{ msg }}</h1>
    <button @click="triggerRay">Send to Ray</button>
  </div>
</template>

<script setup lang="ts">
const msg = ref('Hello Vue Ray!');
const ray = raySetup({
    lifecycleEvents: {
        created: true, // Send 'created' event to Ray
        mounted: true  // Send 'mounted' event to Ray
    }
});

onMounted(() => {
    // Access the ray function via ray.value()
    ray.value().log('MyComponent mounted!').data({ message: msg.value });
});

function triggerRay() {
    ray.value().html('<i>Button clicked from component!</i>').label('interaction');
    try {
        // Simulate an error
        throw new Error('Example error from component!');
    } catch (e: any) {
        // If interceptErrors is true in plugin, this will go to Ray automatically
        // You can also manually send it:
        ray.value().exception(e);
    }
}
</script>

view raw JSON →