Public
Like
like-anything
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
index.ts
https://Jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run
A cross-origin API service that tracks likes using unique IDs.
- Simple ID-based tracking - Use any unique identifier (blog posts, products, comments, etc.)
- Embeddable widget - Drop-in script that creates beautiful like buttons
- Real-time updates - Like counts update instantly across all websites
- CORS enabled - Works from any website or domain
- SQLite storage - Reliable, persistent data storage
<script src="https://jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run/script.js"></script>
<div data-likes-id="your-unique-id"> <button class="likes-button">❤️ <span class="likes-count">0</span></button> </div>
💡 Customize the emoji: Change ❤️ to any emoji you want: 👍 🎉 🚀 ⭐ 🎯 🏆 🎊 🎈 🎁
- Loads current like count automatically
- Handles button clicks to record likes
- Updates count in real-time
- Supports multiple IDs on one page
Record a like for a specific ID:
{ "id": "life-universe-everything" }
Returns:
{ "success": true, "id": "life-universe-everything", "likeCount": 42 }
Get like count for a specific ID:
GET /api/likes/post-123
Returns:
{ "id": "post-123", "likeCount": 42 }
Get total likes across all IDs (for fun)
- Blog posts: Use post IDs like "post-123" or "2024-01-15-intro"
- Products: Use product IDs like "product-abc" or "laptop-xps-13"
- Comments: Use comment IDs like "comment-456" or "reply-789"
- Custom: Any unique identifier you want to track likes for!
// Get current likes for a post
fetch('https://jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run/api/likes/post-123')
.then(res => res.json())
.then(data => {
document.querySelector('.likes-count').textContent = data.likeCount;
});
// Record a like
fetch('https://jamesllllllllll--019894a514b47659ac14319f8b619533.web.val.run/api/like', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ id: 'post-123' })
})
.then(res => res.json())
.then(data => {
// Update the likes count
});
├── backend/
│ └── database.ts # SQLite database setup and queries
├── frontend/
│ └── index.html # Documentation & demo
├── script.js # Embeddable likes widget script
├── index.ts # Main HTTP handler using Hono
└── README.md # This file