An open API service indexing awesome lists of open source software.

https://github.com/august/astro-phantom-forms

A spooky little Astro library that makes your forms invisible to bots. No CAPTCHAs. No honeypots. Just pure, elegant ghostery.
https://github.com/august/astro-phantom-forms

anti-bot anti-spam astro bot-protection cloaking forms hydration no-captcha progressive-enhancement serverless spam-blocking stealth web-components

Last synced: 2 months ago
JSON representation

A spooky little Astro library that makes your forms invisible to bots. No CAPTCHAs. No honeypots. Just pure, elegant ghostery.

Awesome Lists containing this project

README

          

![Phantom Forms for Astro - Spam Bot Prevention](https://raw.githubusercontent.com/august/astro-phantom-forms/main/phantom.webp)

![npm version](https://img.shields.io/npm/v/astro-phantom-forms)

# ๐Ÿ‘ป astro-phantom-forms

## Stop spam bots without annoying humans
### Block form spam with invisible client-side hydration. No CAPTCHAs, no honeypots, no user friction.

![MIT License](https://img.shields.io/badge/license-MIT-green.svg)
![Built for Astro](https://img.shields.io/badge/astro-forms-orange)
![Tests](https://img.shields.io/badge/tests-passing-brightgreen)
![TypeScript](https://img.shields.io/badge/typescript-supported-blue)

> **The Problem**: Spam bots fill out your contact forms, newsletter signups, and comment sections
> **The Solution**: Hide forms from server-side rendering, show them only to real users with JavaScript

---

## โšก Quick Install

```bash
npm install astro-phantom-forms
```

## ๐Ÿš€ Quick Start

Wrap any form with `PhantomForm` to hide it from bots:

```astro
---
import { PhantomForm } from 'astro-phantom-forms';
---





Send Message

```

**Result**: Bots see nothing in the HTML source. Real users see the form when they scroll to it.

---

## ๐Ÿ›ก๏ธ How It Stops Spam

### Traditional Spam Protection (Annoying)
- โŒ **CAPTCHAs**: "Click all the traffic lights"
- โŒ **Honeypot fields**: Extra hidden form fields
- โŒ **Rate limiting**: Block legitimate users too
- โŒ **JavaScript challenges**: Complex bot detection

### Phantom Forms (Invisible)
- โœ… **Zero SSR output**: Forms don't exist in HTML source
- โœ… **Client-only rendering**: JavaScript required to see forms
- โœ… **Progressive enhancement**: Works with any framework
- โœ… **Zero user friction**: Humans never know it's there

**The secret**: Most spam bots don't execute JavaScript. They scrape HTML and find... nothing.

---

## ๐ŸŽฏ Use Cases

### Contact Forms
Stop contact form spam without user verification:

```astro





Send Message

```

### Newsletter Signups
Prevent fake email submissions:

```astro



Subscribe

```

### Login Forms
Protect authentication endpoints:

```astro




Sign In

```

### Comment Systems
Block comment spam:

```astro



Post Comment

```

---

## ๐Ÿ”ง Hydration Modes

Control when forms appear to users:

| Mode | When Forms Load | Best For |
|------|----------------|----------|
| **`load`** | Immediately when page loads | Critical forms (login, checkout) |
| **`idle`** | When browser is idle | Secondary forms (newsletter, feedback) |
| **`visible`** | When scrolled into view | Footer forms, below-fold content |

```astro

```

---

## ๐Ÿ“ฆ Framework Support

Works with all Astro-supported frameworks:

### React Components
```astro
---
import { PhantomForm } from 'astro-phantom-forms';
import ContactForm from '../components/ContactForm.jsx';
---

```

### Vue Components
```astro
---
import { PhantomForm } from 'astro-phantom-forms';
import ContactForm from '../components/ContactForm.vue';
---

```

### Svelte Components
```astro
---
import { PhantomForm } from 'astro-phantom-forms';
import ContactForm from '../components/ContactForm.svelte';
---

```

### Plain HTML Forms
```astro
---
import { PhantomForm } from 'astro-phantom-forms';
---



```

---

## ๐Ÿ” SEO & Accessibility

### Search Engine Friendly
- โœ… **No impact on SEO**: Search engines won't see forms anyway
- โœ… **Progressive enhancement**: Works without JavaScript for indexing
- โœ… **Semantic HTML**: Forms use proper markup when rendered

### Accessibility Compliant
- โœ… **Screen reader compatible**: Forms render normally for assistive tech
- โœ… **Keyboard navigation**: Full keyboard support maintained
- โœ… **Focus management**: Tab order preserved
- โœ… **ARIA attributes**: All accessibility features intact

### Performance Optimized
- โœ… **Zero bundle size**: Uses native Web Components
- โœ… **Lazy loading**: Forms load only when needed
- โœ… **No dependencies**: Pure JavaScript implementation

---

## ๐Ÿ› ๏ธ Advanced Usage

### Multiple Forms Per Page
```astro


```

### Direct Component Import
```astro
---
import PhantomForm from 'astro-phantom-forms/components/PhantomForm.astro';
---

```

### TypeScript Support
Full TypeScript definitions included:

```typescript
interface Props {
mode?: 'load' | 'idle' | 'visible';
}
```

---

## ๐Ÿงช Testing & Development

```bash
# Run tests
npm test

# Build package
npm run build

# Local development
npm link
```

### Verify Spam Protection
Check that forms are hidden from SSR:

```bash
# View source - should show no form elements
curl -s https://yoursite.com/contact | grep -i "
import { PhantomForm } from 'astro-phantom-forms';

import PhantomForm from 'astro-phantom-forms/components/PhantomForm.astro';
```

---

## ๐Ÿ“Š Comparison

| Solution | User Friction | Spam Blocking | SEO Impact | Setup Complexity |
|----------|---------------|---------------|------------|------------------|
| **PhantomForm** | โœ… None | โœ… Excellent | โœ… None | โœ… Minimal |
| CAPTCHA | โŒ High | โœ… Good | โŒ Negative | โŒ Complex |
| Honeypots | โœ… None | โš ๏ธ Moderate | โœ… None | โš ๏ธ Moderate |
| Rate Limiting | โš ๏ธ Some | โš ๏ธ Moderate | โœ… None | โŒ Complex |
| JS Challenges | โš ๏ธ Some | โœ… Good | โš ๏ธ Some | โŒ Complex |

---

## ๐Ÿ’ก Why This Works

### The Bot Problem
Most spam bots:
- ๐Ÿค– Scrape HTML without executing JavaScript
- ๐Ÿค– Submit forms found in static HTML source
- ๐Ÿค– Don't handle client-side rendering
- ๐Ÿค– Target server-side rendered content

### The Phantom Solution
PhantomForm:
- ๐Ÿ‘ป Hides forms from static HTML (bots see nothing)
- ๐Ÿ‘ป Renders forms client-side (humans see everything)
- ๐Ÿ‘ป Uses Web Components (native browser support)
- ๐Ÿ‘ป Leverages Astro's islands architecture

**Result**: 90%+ spam reduction with zero user impact.

---

## ๐Ÿš€ Migration Guide

### From Honeypots
```astro



Submit



Submit

```

### From CAPTCHA
```astro





Submit



Submit

```

---

## ๐ŸŽฏ Keywords & Features

**Spam Protection**: Block form spam, prevent bot submissions, stop automated attacks
**Astro Components**: Form components, client-side rendering, islands architecture
**Anti-Bot**: Bot detection, spam prevention, automated protection
**Web Forms**: Contact forms, newsletter signups, authentication forms
**JavaScript**: Client-side hydration, progressive enhancement, Web Components
**User Experience**: No CAPTCHAs, frictionless forms, invisible protection

---

## ๐Ÿ“š More Resources

- ๐Ÿ“– **[Installation Guide](./INSTALLATION.md)** - Detailed setup instructions
- ๐Ÿ”ง **[Examples](./EXAMPLES.md)** - Real-world usage examples
- ๐Ÿ› **[Troubleshooting](./TROUBLESHOOTING.md)** - Common issues and solutions
- ๐Ÿค **[Contributing](./CONTRIBUTING.md)** - Help improve the project

---

## ๐Ÿ™‹โ€โ™€๏ธ Support

- ๐Ÿ› **Bug reports**: [GitHub Issues](https://github.com/yourusername/astro-phantom-forms/issues)
- ๐Ÿ’ฌ **Questions**: [GitHub Discussions](https://github.com/yourusername/astro-phantom-forms/discussions)
- ๐Ÿ“ง **Security issues**: [Contact privately](mailto:security@yoursite.com)

---

## ๐Ÿ“„ License

MIT License - see [LICENSE.md](./LICENSE.md) for details.

---

**Stop fighting spam. Start using stealth.** ๐Ÿ‘ป

Built with โค๏ธ for the Astro community.