New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@servlyadmin/runtime-vue

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@servlyadmin/runtime-vue

Vue wrapper for Servly runtime renderer

latest
npmnpm
Version
0.1.45
Version published
Maintainers
1
Created
Source

@servlyadmin/runtime-vue

Vue 3 wrapper for Servly runtime renderer. Render Servly components in your Vue applications with full slot support, state management, and reactive updates.

Installation

npm install @servlyadmin/runtime-vue
# or
yarn add @servlyadmin/runtime-vue
# or
pnpm add @servlyadmin/runtime-vue

Requirements

  • Vue 3.0.0 or higher
  • @servlyadmin/runtime-core (installed automatically)

Quick Start

<template>
  <!-- That's it! Components are fetched from Servly's registry automatically -->
  <ServlyComponent
    id="my-component-id"
    :props="{ title: 'Hello World' }"
  />
</template>

<script setup lang="ts">
import { ServlyComponent } from '@servlyadmin/runtime-vue';
</script>

Registry & Caching

Default Registry

Components are fetched from Servly's production registry by default:

  • URL: https://core-api.servly.app/v1/views/registry

To use a custom registry:

import { setRegistryUrl } from '@servlyadmin/runtime-vue';

setRegistryUrl('https://your-api.com/v1/views/registry');

Cache Strategies

The runtime supports three caching strategies:

StrategyDescriptionPersistenceBest For
localStoragePersists across browser sessionsYesProduction (default)
memoryIn-memory cache, cleared on refreshNoDevelopment, SSR
noneNo caching, always fetches freshNoTesting, debugging
<template>
  <!-- Default: localStorage caching -->
  <ServlyComponent id="my-component" />

  <!-- Explicit cache strategy -->
  <ServlyComponent id="my-component" cache-strategy="memory" />

  <!-- No caching -->
  <ServlyComponent id="my-component" cache-strategy="none" />
</template>

API Reference

ServlyComponent Props

PropTypeDefaultDescription
idstringrequiredComponent ID from the registry
versionstring'latest'Version specifier (exact, range, or "latest")
propsobject{}Props to pass to the component
cacheStrategy'localStorage' | 'memory' | 'none''localStorage'Caching strategy
retryConfigobjectundefinedRetry configuration for failed fetches
eventHandlersobjectundefinedEvent handlers keyed by element ID
showSkeletonbooleantrueShow loading skeleton
enableStateManagerbooleanfalseEnable built-in state management
initialStateobjectundefinedInitial state for state manager

Events

EventPayloadDescription
loadComponentDataEmitted when component loads successfully
errorErrorEmitted when component fails to load
stateChangeStateChangeEventEmitted when state changes (if enabled)
readyvoidEmitted when component is fully rendered

Slots

<template>
  <ServlyComponent id="my-component">
    <!-- Custom loading state -->
    <template #fallback>
      <div>Loading...</div>
    </template>
    
    <!-- Custom error state -->
    <template #error="{ error, retry }">
      <div>
        <p>Error: {{ error.message }}</p>
        <button @click="retry">Retry</button>
      </div>
    </template>
    
    <!-- Named slots for component content -->
    <template #header>
      <h1>Custom Header</h1>
    </template>
    
    <template #footer>
      <p>Custom Footer</p>
    </template>
  </ServlyComponent>
</template>

Advanced Usage

With State Management

<template>
  <ServlyComponent
    id="counter-component"
    :props="{ count }"
    enable-state-manager
    :initial-state="{ count: 0 }"
    @state-change="onStateChange"
  />
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { ServlyComponent } from '@servlyadmin/runtime-vue';

const count = ref(0);

const onStateChange = (event) => {
  if (event.key === 'count') {
    count.value = event.value;
  }
};
</script>

With Event Handlers

<template>
  <ServlyComponent
    id="form-component"
    :event-handlers="handlers"
  />
</template>

<script setup lang="ts">
import { ServlyComponent } from '@servlyadmin/runtime-vue';

const handlers = {
  'submit-btn': {
    click: (event) => {
      console.log('Button clicked!', event);
    },
  },
  'email-input': {
    change: (event) => {
      console.log('Email changed:', event.target.value);
    },
  },
};
</script>

Accessing Component Instance

<template>
  <ServlyComponent
    ref="servlyRef"
    id="my-component"
  />
  <button @click="reload">Reload</button>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { ServlyComponent } from '@servlyadmin/runtime-vue';

const servlyRef = ref();

const reload = () => {
  servlyRef.value?.reload();
};

// Other exposed methods:
// servlyRef.value?.getSlotElement('header')
// servlyRef.value?.getSlotNames()
// servlyRef.value?.getStateManager()
// servlyRef.value?.update({ newProp: 'value' })
</script>

Version Specifiers

<template>
  <!-- Exact version -->
  <ServlyComponent id="my-component" version="1.2.3" />
  
  <!-- Caret range (compatible with) -->
  <ServlyComponent id="my-component" version="^1.0.0" />
  
  <!-- Tilde range (approximately) -->
  <ServlyComponent id="my-component" version="~1.2.0" />
  
  <!-- Latest version (default) -->
  <ServlyComponent id="my-component" />
</template>

TypeScript Support

Full TypeScript support is included:

import type {
  ServlyComponentProps,
  BindingContext,
  ComponentData,
  StateChangeEvent,
} from '@servlyadmin/runtime-vue';

Re-exported Utilities

For convenience, common utilities are re-exported:

import {
  // Fetching
  fetchComponent,
  prefetchComponents,
  setRegistryUrl,
  DEFAULT_REGISTRY_URL,
  
  // Caching
  invalidateCache,
  clearAllCaches,
  
  // State management
  StateManager,
  
  // Event system
  EventSystem,
  getEventSystem,
} from '@servlyadmin/runtime-vue';

License

MIT

Keywords

servly

FAQs

Package last updated on 28 Dec 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