Search
mainReference
@karfau
Finds the top level named val that triggered the execution of this val.
(Ignores any untitled vals, since those are sometimes created as an execution context.) By passing a function as the first argument you receive all references as arguments, and can pick or transform them, e.g. @karfau.refToValUrl Possible Limitation: https://discord.com/channels/1020432421243592714/1143386413748994143
Script
(Ignores any untitled vals, since those are sometimes created as an execution context.)
By passing a function as the first argument you receive all references as arguments, and can pick or transform them, e.g.
- [@karfau.refToValUrl](https://val.town/v/karfau.refToValUrl)
export function mainReference<T = ValRef>(transform?: Transform<T>): T {
const stack = new Error().stack;
let refs: ValRef[] = stack.match(/@@({.+?})@@/g).reverse().map((e) =>
CS1200
@asalvat0
// Fetches a random joke.
Cron
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",
emailRandomJoke
@priya_singh_14
// Fetches a random joke.
Cron
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",
fascinatingYellowAntelope
@gaurirajesh733
// Sends an email with the joke.
Script
import { email } from "https://esm.town/v/std/email?v=9";
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",

serverlessMatrixEchoBot
@vlad
A example Serverless Bot for Matrix chat. See https://vlad.roam.garden/How-to-create-a-serverless-Matrix-Chat-bot for a more detailed write-up on how to set one up! To test this bot: invite serverless-echo@matrix.org to your unencrypted room Send a message starting with !echo and the bot will repeat content after. Use https://matrix-serverless.netlify.app/ to configure Matrix to call the endpoint on newly received messages
Express (deprecated)
import { joinMatrixRoom } from "https://esm.town/v/vlad/joinMatrixRoom";
import process from "node:process";
export async function serverlessMatrixEchoBot(
req: express.Request,
res: express.Response,
clearMagentaFlyingfish
@Amr0111
An interactive, runnable TypeScript val by Amr0111
HTTP
export default async function (req: Request): Promise<Response> {
return Response.json({ ok: true })
valle_tmp_0088092323198285537184706961400471
@janpaul123
// Initialize sample stories and store them in blob storage
HTTP
// Initialize sample stories and store them in blob storage
const SAMPLE_STORIES_KEY = "hn_sample_stories";
async function initializeSampleStories() {
const existingStories = await blob.getJSON(SAMPLE_STORIES_KEY);
if (!existingStories) {
versatileWhiteJay
@Love
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
const TMDB_IMAGE_BASE_URL = "https://image.tmdb.org/t/p/w500";
function IndianMovieExplorer() {
const [searchTerm, setSearchTerm] = useState("");
</div>
function client() {
createRoot(document.getElementById("root")).render(<IndianMovieExplorer />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request) {
return new Response(`
nearestOpenStation
@guscuddy
// Forked from @tmcw.nearestOpenStation
Script
lon = +lon;
lat = +lat;
function dist(station) {
return Math.sqrt(
Math.pow(station.lat - lat, 2) + Math.pow(station.lon - lon, 2),

convertTodoItemsToGamePlans
@thomasatflexos
An interactive, runnable TypeScript val by thomasatflexos
Express (deprecated)
redirect: "follow",
let openApiResponse = await fetch(
"https://api.openai.com/v1/chat/completions",
requestOptions,
let jsonResponse = await openApiResponse.json();
valle_tmp_59257570592856375817499399720445
@janpaul123
// This val serves a HTML page that contains a Wordle game with custom CSS for a fun, colorful style
HTTP
if (e.key === 'Backspace') handleBackspace();
function handleKeyPress(letter) {
if (currentCol < 5) {
currentCol++;
function handleSubmit() {
if (currentCol === 5) {
currentCol = 0;
function handleBackspace() {
if (currentCol > 0) {
weatherDashboard
@sany45
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function DeveloperPortfolio() {
const [activeSection, setActiveSection] = useState('about');
fontWeight: 'bold',
function client() {
createRoot(document.getElementById("root")).render(<DeveloperPortfolio />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`
aquamarinePiranha
@maxm
An interactive, runnable TypeScript val by maxm
HTTP
const resp = await fetch("https://maxm-wasmblobhost.web.val.run/e5vpzt253pv5jxqfmygo7nytl5uvyn5c.wasm");
const handler = await wasmHandler(new Uint8Array(await resp.arrayBuffer()));
export default async function(req: Request): Promise<Response> {
return handler(req);
shoppingPlatformAI
@Priyansh
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
function App() {
const [cart, setCart] = useState([]);
useEffect(() => {
async function fetchProducts() {
try {
generateAIRecommendations();
async function generateAIRecommendations() {
try {
const { OpenAI } = await import("https://esm.town/v/std/openai");
const openai = new OpenAI();
const recommendations = await openai.chat.completions.create({
messages: [
setAiRecommendations([
async function handleProductUpload() {
try {
</div>
function client() {
createRoot(document.getElementById("root")).render(<App />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`

cliServer
@pomdtr
An interactive, runnable TypeScript val by pomdtr
Script
const { default: runFn } = await import(url);
if (typeof runFn !== "function") {
throw new Error("Val should have a default export that is a function");
const logs: string[] = [];
const real = target[key];
if (typeof real === "function" && typeof key === "string") {
const fn = function(...args: any[]) {
logs.push(args.join(" "));
return { output: logs.join("\n"), code: 1 };
export function createCli(author: string) {
return new Cli(author);