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=1264&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 19140 results for "function"(2455ms)

paymentGatewayWebmain.tsx4 matches

@Saqib•Updated 3 months ago
3import React, { useState } from "https://esm.sh/react@18.2.0";
4
5function PaymentButton({ method, icon, onClick }) {
6 return (
7 <button
23}
24
25function App() {
26 const [status, setStatus] = useState("Ready to pay");
27
100}
101
102function client() {
103 createRoot(document.getElementById("root")).render(<App />);
104}
105if (typeof document !== "undefined") { client(); }
106
107export default async function server(request: Request): Promise<Response> {
108 if (request.method === "POST" && new URL(request.url).pathname === "/process-payment") {
109 try {

Goldcalculatormain.tsx4 matches

@Madhu3283•Updated 3 months ago
4
5// Custom Logo Component
6function GoldLogo() {
7 return (
8 <svg
50}
51
52function GoldSellCalculator() {
53 const [goldWeight, setGoldWeight] = useState('');
54 const [goldPurity, setGoldPurity] = useState('24');
216}
217
218function client() {
219 const rootElement = document.getElementById("root");
220 if (rootElement) {
227}
228
229export default async function server(request: Request): Promise<Response> {
230 return new Response(`
231 <html>

postHogAPICapturemain.tsx1 match

@BunsDev•Updated 3 months ago
1import { fetch } from "https://esm.town/v/std/fetch";
2
3export async function postHogAPICapture({ key, event, properties, distinct_id }: {
4 key: string;
5 event: string;

FetchBasicmain.tsx1 match

@BunsDev•Updated 3 months ago
1export default async function(req: Request): Promise<Response> {
2 // Setup CORS Headers
3 const headers = new Headers();

browserbaseUtilsmain.tsx2 matches

@toowired•Updated 3 months ago
5}
6
7export async function loadPageContent(url: string, options: LoadPageOptions = { textContent: false }) {
8 const browser = await puppeteer.connect({
9 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,
35}
36
37export async function screenshotPage(url: string, options: ScreenshotOptions = { fullPage: true }) {
38 const browser = await puppeteer.connect({
39 browserWSEndpoint: `wss://connect.browserbase.com?apiKey=${Deno.env.get("BROWSERBASE_API_KEY")}`,

vividBeigeFalconmain.tsx1 match

@lockiechen•Updated 3 months ago
1function add(a: number, b: number) {
2 return a + b;
3}

pngMakerAppmain.tsx3 matches

@g•Updated 3 months ago
6import { Hono } from 'npm:hono';
7
8function html() {
9 /*
10<!DOCTYPE html>
35}
36
37function css() {
38 /*
39body {
86}
87
88function js() {
89 /*
90import { createPolygotPng } from '/polypng.mjs';

oceanThememain.tsx1 match

@paswan•Updated 3 months ago
167 border-radius: 50%;
168 animation: rise infinite;
169 animation-timing-function: linear;
170 }
171

fcReadymain.tsx2 matches

@dbee•Updated 3 months ago
7 console.log("V2 Activated!");
8
9 // Define a global function to add a frame
10 window.addFrame = async () => {
11 try {
17 };
18
19 // Define a global function to close a frame
20 window.closeFrame = async () => {
21 try {

terrificIndigoAlbatrossmain.tsx11 matches

@stevekrouse•Updated 3 months ago
26const PoweredByInfo = "";
27
28function Hero({
29 prompt,
30 setPrompt,
47
48 <p className="text-[#bababa] text-center max-w-[25ch] mx-auto my-4 font-dm-sans">
49 Turn your ideas into fully functional apps in{" "}
50 <span className="relative w-fit text-fuchsia-400 z-10 italic font-semibold rounded-full">
51 less than a second
121}
122
123function App() {
124 const previewRef = React.useRef<HTMLDivElement>(null);
125 const [prompt, setPrompt] = useState("");
175 });
176
177 function handleStarterPromptClick(promptItem: typeof prompts[number]) {
178 setLoading(true);
179 setTimeout(() => handleSubmit(promptItem.prompt), 0);
180 }
181
182 async function handleSubmit(e: React.FormEvent | string) {
183 if (typeof e !== "string") {
184 e.preventDefault();
231 }
232
233 function handleVersionChange(direction: "back" | "forward") {
234 const { currentVersionIndex, versions } = versionHistory;
235 if (direction === "back" && currentVersionIndex > 0) {
920);
921
922function client() {
923 const path = window.location.pathname;
924 const root = createRoot(document.getElementById("root")!);
956}
957
958function extractCodeFromFence(text: string): string {
959 const htmlMatch = text.match(/```html\n([\s\S]*?)\n```/);
960 return htmlMatch ? htmlMatch[1].trim() : text;
961}
962
963async function generateCode(prompt: string, currentCode: string) {
964 const starterPrompt = STARTER_PROMPTS.find(p => p.prompt === prompt);
965 if (starterPrompt) {
1006}
1007
1008export default async function cerebras_coder(req: Request): Promise<Response> {
1009 // Dynamic import for SQLite to avoid client-side import
1010 const { sqlite } = await import("https://esm.town/v/stevekrouse/sqlite");
1109 <meta property="og:site_name" content="Cerebras Coder">
1110 <meta property="og:url" content="https://cerebrascoder.com"/>
1111 <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."">
1112 <meta property="og:type" content="website">
1113 <meta property="og:image" content="https://stevekrouse-blob_admin.web.val.run/api/public/CerebrasCoderOG.jpg">

getFileEmail4 file matches

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

tuna8 file matches

@jxnblk•Updated 3 weeks 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": "*",