Skip to content

Vue

Terminal window
npm install @rep-protocol/vue @rep-protocol/sdk
<script setup lang="ts">
import { useRep, useRepSecure } from '@rep-protocol/vue';
// PUBLIC tier — synchronous, reactive Ref
const apiUrl = useRep('API_URL', 'http://localhost:3000');
const flags = useRep('FEATURE_FLAGS', '');
// SENSITIVE tier — async, resolves after session key fetch
const analyticsKey = useRepSecure('ANALYTICS_KEY');
</script>
<template>
<div>
<p>API: {{ apiUrl }}</p>
<p>Analytics: {{ analyticsKey ?? 'loading...' }}</p>
</div>
</template>

Reads a PUBLIC tier variable as a reactive Ref.

const value: Ref<string | undefined> = useRep('API_URL');
const value: Ref<string | undefined> = useRep('API_URL', 'fallback');
  • Returns a Ref set immediately from the injected payload
  • Automatically updates when the variable changes via hot reload
  • Unsubscribes via onUnmounted — must be called inside setup()

Reads a SENSITIVE tier variable as a reactive Ref.

const analyticsKey: Ref<string | null> = useRepSecure('ANALYTICS_KEY');
  • Starts as null
  • Resolves once the session key fetch and decryption complete
  • Errors are swallowed (the SDK logs them); the ref stays null
  • The decrypted value is cached for the page lifetime

useRep subscribes to the SSE stream on mount and updates the ref automatically. The subscription is cleaned up when the component unmounts.

const apiUrl = useRep('API_URL', 'http://localhost:3000');
  • Vue >= 3.0
  • @rep-protocol/sdk as a peer dependency
  • Composables must be called from setup() for proper onUnmounted cleanup

For the full API reference, see Vue Adapter Reference.