💚
Vue Integration
Integrate NoBlocky with Vue for reactive adblock detection in your Vue applications using composition API and components.
📝 Basic Implementation
Vue 3 Composition API
<script setup> import { ref, onMounted } from 'vue'; import { detectAdblock } from 'noblocky'; const isBlocked = ref(null); const loading = ref(true); onMounted(async () => { try { const result = await detectAdblock({ timeout: 5000, debug: true }); isBlocked.value = result.isBlocked; } catch (error) { console.error('Detection failed:', error); } finally { loading.value = false; } }); </script> <template> <div v-if="loading">Checking...</div> <div v-else> <h2>Adblock Status</h2> <p>{{ isBlocked ? '🚫 Blocked' : '✅ Not Blocked' }}</p> </div> </template>
Composable (Reusable)
// composables/useAdblockDetection.ts import { ref, onMounted } from 'vue'; import { detectAdblock, type NoBlockyResult } from 'noblocky'; export function useAdblockDetection() { const detection = ref<NoBlockyResult | null>(null); const loading = ref(true); onMounted(async () => { const result = await detectAdblock(); detection.value = result; loading.value = false; }); return { detection, loading }; } // Usage in component <script setup> import { useAdblockDetection } from '@/composables/useAdblockDetection'; const { detection, loading } = useAdblockDetection(); </script> <template> <div v-if="!loading"> {{ detection?.isBlocked ? 'Blocked' : 'Clear' }} </div> </template>
Options API (Vue 2/3)
<script> import { detectAdblock } from 'noblocky'; export default { data() { return { isBlocked: null, loading: true }; }, async mounted() { try { const result = await detectAdblock(); this.isBlocked = result.isBlocked; } finally { this.loading = false; } } }; </script>
📦 Installation
Install NoBlocky
npm install @wildebeest-webtech/noblocky
Import in your component
import { detectAdblock } from 'noblocky';⚙️ Advanced Configuration
For complete configuration options including custom detectors, callbacks, timeout settings, and advanced features, visit the advanced configuration page.
View Full Configuration API💡 Pro Tip
Use Vue composables for clean, reactive adblock detection logic. Works with both Vue 2 (with Composition API plugin) and Vue 3!