Val Town Code SearchReturn to Val Town

API Access

You can access search results via JSON API by adding format=json to your query:

https://codesearch.val.run/?q=function&page=1086&format=json

For typeahead suggestions, use the /typeahead endpoint:

https://codesearch.val.run/typeahead?q=function

Returns an array of strings in format "username" or "username/projectName"

Found 17288 results for "function"(1886ms)

StripeDemomain.tsx4 matches

@charmaine•Updated 3 months ago
4import { createRoot } from "https://esm.sh/react-dom/client";
5
6function App() {
7 const [tipAmount, setTipAmount] = useState(5);
8 const paymentLinks = {
63}
64
65function Success() {
66 useEffect(() => {
67 confetti({
81}
82
83function client() {
84 const root = document.getElementById("root");
85 if (root) {
94if (typeof document !== "undefined") { client(); }
95
96export default async function server(request: Request): Promise<Response> {
97 const url = new URL(request.url);
98

cerebras_codermain.tsx11 matches

@GoldGuy•Updated 3 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

scientificCalculatorAppmain.tsx4 matches

@Adool55•Updated 3 months ago
3import { createRoot } from "https://esm.sh/react-dom@18.2.0/client";
4
5function ScientificCalculator() {
6 const [display, setDisplay] = useState("0");
7 const [memory, setMemory] = useState(null);
89}
90
91function App() {
92 return (
93 <div className="app-container">
105}
106
107function client() {
108 createRoot(document.getElementById("root")).render(<App />);
109}
110if (typeof document !== "undefined") { client(); }
111
112export default async function server(request: Request): Promise<Response> {
113 return new Response(`
114 <html>

twitterSearchmain.tsx1 match

@sboesen•Updated 3 months ago
3import { twitterUser } from "https://esm.town/v/stevekrouse/twitterUser";
4
5export async function twitterSearch({
6 query,
7 start_time,

templateTwitterAlertmain.tsx1 match

@valdottown•Updated 3 months ago
12const isProd = false;
13
14export async function twitterAlert({ lastRunAt }: Interval) {
15 // If isProd, search for tweets since that last time this interval ran
16 // if not, search for tweets since 48 hours ago for testing

cerebras_codermain.tsx11 matches

@a10minutedraft•Updated 3 months ago
24);
25
26function Hero({
27 prompt,
28 setPrompt,
45
46 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
47 Turn your ideas into fully functional apps in{" "}
48 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
49 less than a second
116}
117
118function App() {
119 const previewRef = React.useRef<HTMLDivElement>(null);
120 const [prompt, setPrompt] = useState("");
170 });
171
172 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
173 setLoading(true);
174 setTimeout(() => handleSubmit(promptItem.prompt), 0);
175 }
176
177 async function handleSubmit(e: React.FormEvent | string) {
178 if (typeof e !== "string") {
179 e.preventDefault();
226 }
227
228 function handleVersionChange(direction: "back" | "forward") {
229 const { currentVersionIndex, versions } = versionHistory;
230 if (direction === "back" && currentVersionIndex > 0) {
974);
975
976function client() {
977 const path = window.location.pathname;
978 const root = createRoot(document.getElementById("root")!);
1010}
1011
1012function extractCodeFromFence(text: string): string {
1013 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
1014 return htmlMatch ? htmlMatch[1].trim() : text;
1015}
1016
1017async function generateCode(prompt: string, currentCode: string) {
1018 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
1019 if (starterPrompt) {
1060}
1061
1062export default async function cerebras_coder(req: Request): Promise<Response> {
1063 // Dynamic import for SQLite to avoid client-side import
1064 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1163 <meta property="og:site_name" content="Cerebras Coder">
1164 <meta property="og:url" content="https://cerebrascoder.com"/>
1165 <meta property="og:description" content="Turn your ideas into fully functional apps in less than a second – powered by Llama3.3-70b on Cerebras's super-fast wafer chips. Code is 100% open-source, hosted on Val Town."">
1166 <meta property="og:type" content="website">
1167 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

cafetiraCafeAndBilliardTournamentmain.tsx3 matches

@Kpool•Updated 3 months ago
3import React, { useEffect, useState } from "https://esm.sh/react@18.2.0";
4
5function App() {
6 const [selectedCategory, setSelectedCategory] = useState("cafe");
7 const [playerName, setPlayerName] = useState("");
390};
391
392function client() {
393 createRoot(document.getElementById("root")).render(<App />);
394}
395if (typeof document !== "undefined") { client(); }
396
397export default async function server(request: Request): Promise<Response> {
398 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
399 const KEY = "cafetiraCafeAndBilliardTournament";

terrificBlueWhippetmain.tsx1 match

@anshumanpatha•Updated 3 months ago
120 const fireworksContainer = document.querySelector('.fireworks');
121
122 function createFirework() {
123 const firework = document.createElement('div');
124 firework.className = 'firework';

ardentVioletSwordfishmain.tsx4 matches

@rahul97•Updated 3 months ago
28};
29
30function SnakeGame() {
31 const [difficulty, setDifficulty] = useState('normal');
32 const [level, setLevel] = useState(1);
42
43 // Generate random food position
44 function generateFoodPosition() {
45 return {
46 x: Math.floor(Math.random() * boardSize),
262}
263
264function client() {
265 createRoot(document.getElementById("root")).render(<SnakeGame />);
266}
268if (typeof document !== "undefined") { client(); }
269
270export default async function server(request: Request): Promise<Response> {
271 return new Response(`
272 <html>

passkeys_demomain.tsx3 matches

@maxm•Updated 3 months ago
23console.log("hi");
24// UTILS
25function generateJWT(userId: string) {
26 return new SignJWT({ userId }).setProtectedHeader({ alg: "HS256" }).sign(SECRET);
27}
28function verifyJWT(token: string) {
29 return jwtVerify(token, SECRET);
30}
31function generateRandomString() {
32 return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
33}

getFileEmail4 file matches

@shouser•Updated 1 week ago
A helper function to build a file's email
tuna

tuna8 file matches

@jxnblk•Updated 1 week ago
Simple functional CSS library for Val Town
webup
LangChain (https://langchain.com) Ambassador, KubeSphere (https://kubesphere.io) Ambassador, CNCF OpenFunction (https://openfunction.dev) TOC Member.
lost1991
import { OpenAI } from "https://esm.town/v/std/openai"; export default async function(req: Request): Promise<Response> { if (req.method === "OPTIONS") { return new Response(null, { headers: { "Access-Control-Allow-Origin": "*",