🚀

Astro Integration

Integrate NoBlocky with Astro's island architecture for optimal performance with client-side adblock detection.

📝 Basic Implementation

Astro Component (.astro)

---
// src/components/AdblockDetector.astro
---

<div id="adblock-status">
  <p>Checking adblock status...</p>
</div>

<script>
  import { detectAdblock } from 'noblocky';

  async function checkAdblock() {
    const statusEl = document.getElementById('adblock-status');
    
    try {
      const result = await detectAdblock({
        timeout: 5000,
        debug: true
      });

      if (statusEl) {
        statusEl.innerHTML = result.isBlocked
          ? '🚫 Adblock detected'
          : '✅ No adblock detected';
      }
    } catch (error) {
      console.error('Detection failed:', error);
      if (statusEl) {
        statusEl.innerHTML = '❌ Detection failed';
      }
    }
  }

  // Run detection when component loads
  checkAdblock();
</script>

Use in Astro Page

---
// src/pages/index.astro
import Layout from '../layouts/Layout.astro';
import AdblockDetector from '../components/AdblockDetector.astro';
---

<Layout title="Welcome">
  <h1>Welcome to my site</h1>
  <AdblockDetector />
</Layout>

📦 Installation

1. Install NoBlocky

npm install @wildebeest-webtech/noblocky

2. Import and Use

NoBlocky works seamlessly with Astro's island architecture. Simply import it in your component's client-side script.

⚙️ 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

Astro's island architecture means NoBlocky only loads on the client side, keeping your build-time fast and your bundles small. Perfect for static sites with selective hydration!

© 2025 NoBlocky. Adblock detection library.