Search

Results include substring matches and semantically similar vals. Learn more
Olive avatar
linkInBioTemplate
@Olive
* This web app creates a Side School Seminar location voting system. * Users can vote for their preferred seminar location from four options. * The app uses React for the frontend and SQLite for storing votes on the backend. * The design is inspired by Side.school and includes an image in the first frame. * It features a celebration animation when voting, a distinct style for the selected option, * and allows users to cancel their vote by clicking on the selected option again.
HTTP
* This web app creates a Side School Seminar location voting system.
* The app uses React for the frontend and SQLite for storing votes on the backend.
* The design is inspired by Side.school and includes an image in the first frame.
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
<h1>Side School Seminar</h1>
function client() {
client();
<title>Side School Seminar</title>
bennybowden avatar
coffeeBrewApp
@bennybowden
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
"Fold Chemex filter into quadrant with three layers on one side",
"Place filter in Chemex with three-layer side against spout",
<ul className="list-disc list-inside pl-4 text-gray-700">
<ol className="list-decimal list-inside pl-4 text-gray-700">
function client() {
// Only run client-side code in a browser environment
client();
ejfox avatar
typingTestSpectrogram
@ejfox
// This app creates a 10-second typing test with audio recording and spectrogram visualization.
HTTP
// TailwindCSS is used for styling.
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect, useRef } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
</div>
function client() {
console.log("Client-side code running");
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
async function server(request: Request): Promise<Response> {
janpaul123 avatar
reacttldrawclient
@janpaul123
tldraw example with builder, for consistent React versions.
Script
tldraw example with builder, for consistent React versions.
/** @jsxImportSource https://esm.sh/react@18.3.1 **/
"react-dom": "18.3.1",
"react": "18.3.1",
export * as ReactDOM from "react-dom";
export * as React from "react";
ReactDOM,
React,
<tldraw.Tldraw persistenceKey="valtown_reacttldrawclient" cameraOptions={{ wheelBehavior: "zoom" }} />
// The app will be rendered inside the root div
const root = ReactDOM.createRoot(document.getElementById("root"));
mikehiggins avatar
sanguineCyanMastodon
@mikehiggins
Project Name: Radical Text Analyser Primary Purpose: A web-based text analysis tool that counts words, calculates TF-IDF, analyzes sentiment, and generates fun facts about the input text. Main Technologies: Hono framework, HTML parsing, JS Base64 encoding, and Node.js. Word and character counts TF-IDF score calculation for the importance of phrases Word frequency analysis Basic sentiment analysis (positive, negative, or neutral) Fun fact generation about the text (e.g., average word length) Summary generation The tool is implemented in JavaScript using Hono as a lightweight framework and integrates web APIs for fetching external content and analyzing it in real-time. Code Structure Imports Hono: Used for routing and handling API requests. encode (from JS Base64): Utility for encoding data. parse (from Node HTML Parser): Parses HTML content, used in fetchUrlContent to clean and extract text. Core Modules app: Initializes the main app instance with Hono. stopwords: Contains a list of common stop words and web-specific terms to filter out during text analysis. synonyms: Dictionary mapping common words to their synonyms for highlighting in TF-IDF analysis. Functions The primary functions perform specific text analysis tasks, as detailed in the following sections. Function Documentation Each function's purpose, parameters, and output are described below, along with notes on how they are used within the application. analyseSentiment(text) Purpose: Analyzes the sentiment of a given text. Parameters: text (string): The text to be analyzed. Returns: An object with score (numerical sentiment score) and sentiment (positive, neutral, or negative). Usage: Called within the /analyse endpoint to evaluate the overall sentiment of the user’s input. calculateTFIDF(text, outputSize=7) Purpose: Calculates TF-IDF scores to measure the importance of words/phrases in the text. Parameters: text (string): The text for analysis. outputSize (number, optional): Limits the number of phrases to return. Returns: Array of top phrases with scores, filtered for uniqueness and length constraints. Usage: Called in /analyse to highlight significant terms. calculateWordFrequency(text, topN=30) Purpose: Counts word frequency, excluding stop words and web-specific terms. Parameters: text (string): Input text. topN (number, optional): Number of top words to return. Returns: Array of most frequent words with counts. Usage: Used within /analyse to populate the word frequency analysis section. generateFunFact(text) Purpose: Generates a fun fact based on text statistics (e.g., word length). Parameters: text (string): Text for analysis. Returns: String with a randomly chosen fun fact. Usage: Triggered in /analyse to add a unique, informational element to results. generateSummary(text, sentenceCount=3) Purpose: Extracts a summary from the first few sentences of the input. Parameters: text (string): Text for summarization. sentenceCount (number, optional): Number of sentences in the summary. Returns: Summary string. Usage: Included in /analyse for quick overviews. cleanText(text) Purpose: Cleans HTML and unwanted characters from the fetched content. Parameters: text (string): Raw HTML/text. Returns: Cleaned text string. Usage: Essential for preprocessing content in fetchUrlContent. fetchUrlContent(url) Purpose: Fetches HTML content from a URL, removes unwanted elements, and extracts main text. Parameters: url (string): URL to fetch and clean content from. Returns: Cleaned text string or an error message. Usage: This function powers the URL input functionality. Core Functionalities Text Analysis Form (HTML) The form on the main page allows users to submit either raw text or a URL. The client-side JavaScript processes the form submission and, if needed, triggers a URL fetch to obtain content. Backend Processing (Routes) GET /: Serves the main HTML page. POST /analyse: Analyzes submitted text and returns word count, sentiment, summary, TF-IDF, and word frequency results. POST /fetch-url: Retrieves and cleans content from a URL, then prepares it for analysis. Dark Mode and Interactivity Dark Mode Toggle: Client-side JavaScript manages style changes. Share Feature: Allows users to copy a link with encoded text or URL. Word Cloud: jQCloud generates a word cloud based on frequency data. Maintenance Notes Testing Integration Tests: Ensure calculateTFIDF, calculateWordFrequency, and fetchUrlContent produce consistent outputs. Client-Side Testing: Regularly test URL fetching functionality to ensure robustness, particularly with dynamic sites. Error Handling Maintain try/catch blocks in asynchronous functions like fetchUrlContent to capture network issues. Update error messages to be user-friendly and provide feedback if inputs are invalid or exceed size limits. Data Sanitization Verify that cleanText removes sensitive information from fetched URLs to prevent accidental disclosure. Rate Limits and API Usage Consider implementing rate limiting or caching mechanisms to manage heavy usage or repeated requests for the same content. Future Improvements Enhanced Synonym Dictionary Expand synonyms for better word variation support during analysis. Advanced Sentiment Analysis Implement a sentiment analysis library or API for more nuanced scoring and classification. Multilingual Support Extend stop words, sentiment analysis, and cleaning functions to support languages beyond English. The Radical Text Analyser code primarily uses the following APIs: Hono Framework API Purpose: Used to set up routing and serve responses for different endpoints (GET /, POST /analyse, and POST /fetch-url). Usage: The Hono framework handles HTTP requests and responses, forming the backbone of the server-side API. External Content Fetching API (via fetch) Purpose: Retrieves HTML content from external URLs when users input a URL for analysis. Usage: The fetchUrlContent function uses fetch to make a GET request to the user-provided URL, which allows the application to process content from web pages. Error Handling: Includes logic to check response status and handle various network errors. Google Fonts API Purpose: Loads the "VT323" font for styling the front-end. Usage: Linked in the HTML section via . jQCloud Library (via CDN) Purpose: Used for generating a word cloud from frequency data on the client side. Usage: Loaded in the HTML section with and The TF-IDF analysis in this code is performed without using an external library. Instead, it’s implemented directly in the calculateTFIDF function. Here’s how it works: Tokenization and Filtering : The text is split into words and phrases, excluding stopwords and web-specific terms. Term Frequency (TF) : For each unique phrase, the code calculates how frequently it appears in the text relative to the total number of words. Inverse Document Frequency (IDF) : Each term’s IDF is calculated using a formula that reduces the weight of commonly occurring phrases. Scoring : TF and IDF are multiplied, adjusted by phrase length and rarity, to boost significant phrases. Output : Top phrases are sorted by score, filtered for uniqueness, and returned as the most relevant terms. This custom implementation allows for added customization, such as phrase filtering and length adjustments, which wouldn’t be as easily configurable with a standard library. IDF = ln(Total Word Count / Document Frequency of Term) + 1 Total Word Count: The total number of words in the input text. Document Frequency of Term: How many times the term appears across documents, which is set to 1 in this single-document context to avoid division by zero. +1 Adjustment: Adding 1 ensures that terms appearing once don't have an IDF of zero, which would nullify their score.
HTTP
e form on the main page allows users to submit either raw text or a URL. The client-side JavaScript processes the form submis
Dark Mode Toggle: Client-side JavaScript manages style changes.
Client-Side Testing: Regularly test URL fetching functionality to ensure robustness, particularly with dynamic sites.
Consider implementing rate limiting or caching mechanisms to manage heavy usage or repeated requests for the same content.
* Usage: The Hono framework handles HTTP requests and responses, forming the backbone of the server-side API.
/** @jsxImportSource https://esm.sh/react */
import React, { useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function client() {
client();
all avatar
TufteCSS
@all
CSS Explorer [ ] Add Flexgrid [x] Pill box style navigation [ ] Tufte-inspired CSS [ ] React [ ] Lorum Ipsum Text Sample with all features [ ] Admonishments [ ] MARP explorer with navigation buttons [ ] Edit sliders to left [ ] Colors on Bottom [ ] "Scramble" Feature [ ] Full CSS download
HTTP
- [ ] Tufte-inspired CSS
- [ ] React
- [ ] Lorum Ipsum Text Sample with all features
* This val creates a Tufte-inspired CSS Navigator app with React for the client-side UI
* and a server-side handler for serving the HTML. The app allows users to explore different
* CSS styles, copy and download them, change themes, view sample text that displays
* the selected style, choose accent colors, and adjust extra options like font size and line height.
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
const cssStyles = {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
export default async function server(request: Request): Promise<Response> {
movienerd avatar
clickerGame
@movienerd
* This clicker game allows users to earn virtual money by clicking. * It includes an upgrade system where users can purchase multiple auto-clickers, dime-smithers, quarter-makers, dollar-mills, twoonie-transformers, fiver-factories, ten-trackers, twenty-detectors, fifty-forgers, and hundred-hewers. * Each upgrade adds to the overall effect, increasing earnings per second. * Upgrades are hidden until they are unlocked for the first time. * The game state is stored client-side using localStorage for persistence. * React is used for the UI, and setInterval for the auto-upgrade functionality.
HTTP
* Upgrades are hidden until they are unlocked for the first time.
* The game state is stored client-side using localStorage for persistence.
* React is used for the UI, and setInterval for the auto-upgrade functionality.
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
setMoney(m => m + 0.01);
const buyUpgrade = (cost: number, setter: React.Dispatch<React.SetStateAction<number>>) => {
if (money >= cost) {
const formatMoney = (amount: number) => amount.toFixed(2);
nst renderUpgradeButton = (name: string, cost: number, count: number, setter: React.Dispatch<React.SetStateAction<number>>, u
if (!unlocked) return null;
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
async function server(request: Request): Promise<Response> {
pomdtr avatar
example_ssr
@pomdtr
SSR + Hydration Demo Look at @pomdtr/island and @pomdtr/hydrate_islands to read the whole library source code (less than 50 rows!).
HTTP
/** @jsxImportSource https://esm.sh/react */
import { useEffect, useState } from "https://esm.sh/react";
// will run on both client and server
export function Demo(props: { items: string[] }) {
useEffect(() => {
items.push("This item is rendered only on the client, after the hydration");
setItems([...items]);
if (url.pathname == "/api/item") {
return Response.json("This item is fetched from the server by the client");
// server-side import should only be used here
const { Island } = await import("https://esm.town/v/pomdtr/island");
const { renderToString } = await import("https://esm.sh/react-dom/server");
return new Response(
items={[
"This item is rendered both on the server and the client",
</Island>
richi1969 avatar
AboutNoelandLiam
@richi1969
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function FAQ({ question, answer }) {
answer: "The band broke up due to constant tensions between Liam and Noel Gallagher, with a final backstage argument in
question: "Have Liam and Noel ever considered reuniting?",
answer: "Despite fan hopes, both brothers have consistently dismissed reunion possibilities, maintaining their public f
</div>
function client() {
createRoot(document.getElementById("root")).render(<GallagherArticle />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
nirwan avatar
Attendence
@nirwan
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
import React, { useState, useEffect, useRef } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function AttendanceApp() {
</div>
function client() {
createRoot(document.getElementById("root")).render(<AttendanceApp />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP
// Server-side route handling
if (request.method === 'POST' && new URL(request.url).pathname === '/submit-attendance') {
movienerd avatar
clicker
@movienerd
This is a simple idle clicker game written almost entirely by AI and directed by prompts.
HTTP
* This code creates a Money Clicker Game using React for the UI.
* It uses localStorage for client-side persistence and setInterval for auto-upgrades.
* The game features a pixelated, retro-inspired design reminiscent of early computer games.
* The upgrade-info-container is now hidden when not on the Clickers tab.
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
setMoney(m => m + 0.01);
const buyUpgrade = (cost: number, setter: React.Dispatch<React.SetStateAction<number>>) => {
if (money >= cost) {
count: number,
setter: React.Dispatch<React.SetStateAction<number>>,
unlocked: boolean,
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
async function server(request: Request): Promise<Response> {
Shigigami avatar
chatApplication
@Shigigami
hi
HTTP
/** @jsxImportSource https://esm.sh/react@18.2.0 */
import React, { useState, useEffect, useRef } from "https://esm.sh/react@18.2.0";
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
<div className="sidebar">
<div className="sidebar-header">
function client() {
if (typeof document !== "undefined") { client(); }
.sidebar {
.sidebar-header {
.sidebar {
sharanbabu avatar
aiTextEditor
@sharanbabu
* This val creates a text editing tool using the Cerebras Llama 70B model. * It includes a command input field with speech-to-text functionality, a collapsible additional context area, * and a rich text editor. The user's command, additional context, and current text are sent to the Cerebras API, * which returns the modified text to be displayed in the editor. * We use React for the UI, the Web Speech API for speech recognition, and the Cerebras API for text processing.
HTTP
* We use React for the UI, the Web Speech API for speech recognition, and the Cerebras API for text processing.
// Server-side code
const client = new Cerebras({
const completion = await client.chat.completions.create({
<link href="https://esm.sh/react-quill@2.0.0/dist/quill.snow.css" rel="stylesheet">
import React, { useState, useRef, useEffect } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import ReactQuill from "https://esm.sh/react-quill";
return React.createElement(
React.createElement("h1", null, "My AI Pen✒️"),
all avatar
townGen
@all
townGen [[https://www.val.town/v/all/promptGen]] [[https://www.val.town/v/stevekrouse/valwriter]] Note : It looks like openai enhancement was dropped at some point when adding all the gizmos;
HTTP
* Sub-functionalities are now listed under the main functionality to help describe it better.
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
// Simulated API for Hono and Deno features
frontend: [
"react",
"vue",
"aframe",
"react-three-fiber",
"cannon-es",
"Use modern CSS techniques",
"Add client-side form validation",
"Implement lazy loading for images",
"Use Web Workers for background tasks",
"Ensure it works properly in both server and client environments",
"Add offline support with Service Workers",
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") {
client();
async function server(request: Request): Promise<Response> {
kian avatar
webcamEffects
@kian
* This app creates a webcam-based image processing application with spooky effects. * It requests webcam permissions, displays the video feed, and applies visual and audio effects. * We use React for the UI, the browser's MediaDevices API for webcam access, * and Web Audio API for continuous audio effects.
HTTP
* It requests webcam permissions, displays the video feed, and applies visual and audio effects.
* We use React for the UI, the browser's MediaDevices API for webcam access,
* and Web Audio API for continuous audio effects.
/** @jsxImportSource https://esm.sh/react */
import React, { useEffect, useRef, useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
</div>
// client-side only code
function client() {
createRoot(document.getElementById("root")!).render(<App />);
if (typeof document !== "undefined") { client(); }
// server-side only code
export default async function server(request: Request): Promise<Response> {