npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@servlyadmin/runtime-vue

v0.1.43

Published

Vue wrapper for Servly runtime renderer

Downloads

1,045

Readme

@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:

| Strategy | Description | Persistence | Best For | |----------|-------------|-------------|----------| | localStorage | Persists across browser sessions | Yes | Production (default) | | memory | In-memory cache, cleared on refresh | No | Development, SSR | | none | No caching, always fetches fresh | No | Testing, 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

| Prop | Type | Default | Description | |------|------|---------|-------------| | id | string | required | Component ID from the registry | | version | string | 'latest' | Version specifier (exact, range, or "latest") | | props | object | {} | Props to pass to the component | | cacheStrategy | 'localStorage' \| 'memory' \| 'none' | 'localStorage' | Caching strategy | | retryConfig | object | undefined | Retry configuration for failed fetches | | eventHandlers | object | undefined | Event handlers keyed by element ID | | showSkeleton | boolean | true | Show loading skeleton | | enableStateManager | boolean | false | Enable built-in state management | | initialState | object | undefined | Initial state for state manager |

Events

| Event | Payload | Description | |-------|---------|-------------| | load | ComponentData | Emitted when component loads successfully | | error | Error | Emitted when component fails to load | | stateChange | StateChangeEvent | Emitted when state changes (if enabled) | | ready | void | Emitted 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