Search
ingeniousAmberBird
@lcarbonaro
An interactive, runnable TypeScript val by lcarbonaro
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({
name: "valtown",

sqlite
@saolsen
This is a wrapper of the val town std sqlite library that adds tracing via https://www.val.town/v/saolsen/tracing.
Script
import { InStatement, sqlite as std_sqlite } from "https://esm.town/v/std/sqlite?v=4";
import { get_tracer } from "https://esm.town/v/saolsen/tracing?v=136";
async function traced_execute(statement: InStatement): Promise<ResultSet> {
return await get_tracer().startActiveSpan(`sqlite:execute`, async (span) => {
if (span.isRecording()) {
} finally {
span.end();
async function traced_batch(statements: InStatement[], mode?: TransactionMode): Promise<ResultSet[]> {
return await get_tracer().startActiveSpan(`sqlite:batch`, async (span) => {
if (span.isRecording()) {
obedientPeachPheasant
@johncassidy18
// Fetches a random joke.
Cron
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",

nixpkgs
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
mode: "search",
} as const satisfies sunbeam.Manifest;
async function search(query: string): Promise<sunbeam.ListItem[]> {
if (query.length === 0) return [];
const response = await fetch(
exampleP5sketch
@moe
Example p5 sketch
HTTP
export default sketch(import.meta.url, title)
export function setup() {
// console.log("setup", window.innerWidth, window.innerHeight);
createCanvas(500, 500)
export function draw() {
background(0)
ellipse(mouseX, mouseY, 180, 180)
export function keyPressed() {
if (key == "i") {
saveGif("p5js-" + new Date().getTime(), 12, {})
// export function touchEnded() {
// saveCanvas("p5js-" + new Date().getTime(), "png");
esmTown
@jdan
wordGame A wordgame inspired by TextTwist. Custom games can be created by appending the available letters to the url. https://jdan-esmtown.web.val.run/nsetyr The dictionary is populated from the following script: import { blob } from "https://esm.town/v/std/blob?v=12";
const dictionaryUrls = [
"https://www.freescrabbledictionary.com/word-lists/3-letter-words/3-letter-words.json",
"https://www.freescrabbledictionary.com/word-lists/4-letter-words/4-letter-words.json",
"https://www.freescrabbledictionary.com/word-lists/5-letter-words/5-letter-words.json",
"https://www.freescrabbledictionary.com/word-lists/6-letter-words/6-letter-words.json",
"https://www.freescrabbledictionary.com/word-lists/7-letter-words/7-letter-words.json",
];
const allWords = await Promise.all(
dictionaryUrls.map(async (url) => {
const res = await fetch(url);
const words = await res.json();
return words.map((entry) => entry.word);
}),
);
blob.setJSON("words", allWords.flat());
HTTP
import { wordsMatching } from "https://esm.town/v/jdan/wordsMatching";
import { Hono } from "npm:hono@3";
function esmTown(url) {
return fetch(url, {
headers: {
labLoginBanUser
@todepond
An interactive, runnable TypeScript val by todepond
HTTP
import * as bcrypt from "https://deno.land/x/bcrypt@v0.4.1/mod.ts";
import { sqlite } from "https://esm.town/v/std/sqlite";
export default async function(req: Request): Promise<Response> {
const TABLE_NAME = "lab_login_users_with_times";
const body = await req.json();
patronum
@effector
An interactive, runnable TypeScript val by effector
Script
export async function patronum() {
const patronum = await import("https://esm.sh/patronum@1.19.1");
return patronum;
efficientBronzeKoi
@aszeto99910
// Fetches a random joke.
Script
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
website_Summarizer
@arfan
@jsxImportSource https://esm.sh/react
HTTP
function ProgressBar({ progress }) {
function SiteDetails({ siteInfo }) {
function App() {
function client() {
console.log("Client function called");
console.log("Document already loaded, calling client immediately");
export default async function server(request: Request): Promise<Response> {
console.log("Server function called", request.method, request.url);
window.addEventListener('load', function() {
setTimeout(function() {
pinkEgret
@maxm
// import { Request, Response } from "./node_modules/express/index.js";
HTTP
// import { Request, Response } from "./node_modules/express/index.js";
export default async function(req: Request): Promise<Response> {
console.log("Request received:", req);
try {
agileApricotPossum
@Koka
@jsxImportSource https://esm.sh/react@18.2.0
Script
// Gamification and Progress Tracking
function UserProgress() {
const [points, setPoints] = useState(0);
// Pomodoro Focus Timer
function PomodoroTimer() {
const [timeLeft, setTimeLeft] = useState(25 * 60);
// Main App Component
function StudySparkApp() {
const [courses, setCourses] = useState([]);
// Client-side rendering
function client() {
createRoot(document.getElementById("root")).render(<StudySparkApp />);
// Server-side rendering
export default async function server(request: Request): Promise<Response> {
// Future: Integrate OpenAI for AI-powered task breakdown
// const { OpenAI } = await import("https://esm.town/v/std/openai");
return new Response(
inclinedAmethystAardvark
@talha_husnain
// Track which players have folded
Script
function generateDeck() {
function parseHand(handStr) {
function shuffleDeck(deck) {
function generateAllHands(deck) {
function getHandRanks(cards) {
function countOccurrences(arr) {
function isFlush(cards) {
function isStraight(ranks) {
function evaluateHand(cards) {
function precomputeOpponentHands(vpipArray, deck, heroHand) {

hono_react_ssr
@stevekrouse
Hono React SSR Development in progress
Script
</form>
export const middleware = (importMetaURL: string) =>
async function(req: Request): Promise<Response> {
const { author, name } = extractValInfo(importMetaURL);
const valURL = `https://www.val.town/v/${author}/${name}`;
GDI_deepThinkAbout
@rozek
This val is part of a series of examples to introduce "val.town" in my computer science course at
Stuttgart University of Applied Sciences . The idea is to motivate even first-semester students not to wait but to put their
ideas into practice from the very beginning and implement web apps with
frontend and backend. It contains a single function which is exported in order to be used by other
code (e.g., other vals). This val is the companion of https://www.val.town/v/rozek/GDI_DeepThought/ which imports this function and invokes it. The code was created using Townie - with only a few small manual corrections. This val is licensed under the MIT License.
Script
frontend and backend.
It contains a single function which is exported in order to be used by other
code (e.g., other vals).
[https://www.val.town/v/rozek/GDI_DeepThought/](https://www.val.town/v/rozek/GDI_DeepThought/)
which imports this function and invokes it.
The code was created using Townie - with only a few small manual corrections.
export default function deepThinkAbout (Question:string):string {
return "42" // unfortunately, we cannot wait 7.5 million years...