Search
BestTime2post
@taurusismagic
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
].slice(0, 6); // Limit to first 6 platforms for performance
function useTimeout(callback, delay) {
useEffect(() => {
}, [callback, delay]);
function App() {
const [step, setStep] = useState(1);
</div>
function renderApp() {
const root = document.getElementById("root");
console.error("Root element not found");
function client() {
if (document.readyState === "loading") {
client();
export default async function server(request: Request): Promise<Response> {
const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
constantPeachPorcupine
@ozhao1323
// 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 = fetch(
"https://official-joke-api.appspot.com/random_joke",
ardentBrownHerring
@joshua_moshes
// 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",
merryOrangeEgret
@briannafountain
// Fetches a random joke.
Script
import { email } from "https://esm.town/v/std/email?v=9";
// Fetches a random joke.
function fetchRandomJoke() {
const SAMPLE_JOKE = {
"setup": "What do you call a group of disorganized cats?",
// ... imports ...
// Fetches a random joke.
async function fetchRandomJoke() {
const response = await fetch(
"https://official-joke-api.appspot.com/random_joke",
fastCoffeeLizard
@mvmattgray
An interactive, runnable TypeScript val by mvmattgray
HTTP
export default async (request) => {
const secret = "cfbd87a697526bf25127f998fe6388684b80524be46062a1a79d6dd26b5a6b90";
async function verifySignature(bodyText, receivedSignature) {
const encoder = new TextEncoder();
const keyData = encoder.encode(secret);
</div>
<script>
async function fetchData() {
try {
const response = await fetch(window.location.href, { headers: { 'accept': 'application/json' } });
mathemagic
@gueejla
UI for mathematical visualizations and calculations
HTTP
import { blob } from "https://esm.town/v/std/blob";
import { renderToString } from "npm:react-dom/server";
export default async function(req: Request): Promise<Response> {
const spellList = await blob.list();
const spells: any[] = [];
val_9TUgqVP5PQ
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export default async function handler(req) {
try {
const result = await (async () => {
function isPrime(num) {
if (num <= 1) return false;
return true;
function findLowestThreeDigitPrime() {
for (let num = 100; num < 1000; num++) {
oktrue
@all
@jsxImportSource https://esm.sh/react
HTTP
import { createRoot } from "https://esm.sh/react-dom/client";
function App() {
return (
</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(`
notion_paperpile_detail_filler
@nerdymomocat
An interactive, runnable TypeScript val by nerdymomocat
Cron
import { Client } from "npm:@notionhq/client";
import { fetch } from "npm:cross-fetch";
export default async function(interval: Interval) {
const NOTION_API_KEY = process.env.NOTION_API_KEY;
const PAPERPILE_DB_ID = "DB_ID_GOES_HERE";
encodeURIComponent(
fields,
).then((r) => r.json()).catch(function() {
console.log("Promise Rejected");
if (!(j.total > 0)) {
postTweet
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
import { fetchJSON } from "https://esm.town/v/stevekrouse/fetchJSON?v=41";
export async function postTweet({ accessToken, text, reply }: {
accessToken: string;
text: string;
InstantSearchAlgoliaStoryTest
@willthereader
An interactive, runnable TypeScript val by willthereader
HTTP
import { configure, hits, pagination, searchBox } from "https://esm.sh/instantsearch.js@4.49.1/es/widgets";
function validateConfig(): { appId: string; apiKey: string } {
const appId = Deno.env.get("ALGOLIA_APP_ID");
return { appId, apiKey };
function generateHtml(appId: string, apiKey: string): string {
console.log("Generating HTML with App ID:", appId, "and API Key:", apiKey ? "exists" : "missing");
templates: {
item: function(hit) {
console.log('Hit:', hit); // Add this line
</html>
function handleError(error: Error): Response {
console.error("Server error:", error);
return new Response(`Error: ${error.message}`, { status: 500 });
async function handleRequest(request: Request): Promise<Response> {
console.log("Received request:", request.url);
GDI_SSEService
@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 simple HTTP end point which starts sending a countdown from 10 to 0 using "Server-sent
Events" (SSE) This val is the companion of https://rozek-gdi_sse.web.val.run/ which contains the browser part (aka "frontend") for this example. The code was initially created using Townie - but this time it required a lot of manual corrections. This val is licensed under the MIT License.
HTTP
export default async function (req: Request): Promise<Response> {
// Only handle GET requests
if (req.method !== 'GET') {
web_Q99YAJsL65
@dhvanil
An interactive, runnable TypeScript val by dhvanil
HTTP
export async function web_Q99YAJsL65(req) {
return new Response(`<!DOCTYPE html>
<html>
thewaningmoon
@nabnab
Hello!!! I made this thing for you i hope you like it. i hope it works first and foremost cuz i saw a tutorial and i copied the code and did some changes so i hope it works RAHHH!!
HTTP
"one more time pleekie",
function App() {
const [noClicks, setNoClicks] = useState(0);
</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(
dynamicBronzeOx
@Afaaques12
@jsxImportSource https://esm.sh/react@18.2.0
HTTP
"Straight line: Practical, logical mindset"
function PalmistryApp() {
const [selectedLine, setSelectedLine] = useState(null);
</div>
function client() {
createRoot(document.getElementById("root")).render(<PalmistryApp />);
if (typeof document !== "undefined") { client(); }
export default async function server(request: Request): Promise<Response> {
return new Response(`