Search

Results include substring matches and semantically similar vals. Learn more
Negash avatar
reactExample
@Negash
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
export const reactExample = modifyFetchHandler(async (request: Request) => {
const url = new URL(request.url);
if (url.pathname === "/favicon.ico") return new Response(null, { status: 404 });
const [, , data] = await sqlite.batch([
"CREATE TABLE IF NOT EXISTS stevekrouse_com_hits (timestamp DATETIME DEFAULT CURRENT_TIMESTAMP)",
"INSERT INTO stevekrouse_com_hits DEFAULT VALUES",
"SELECT COUNT(*) FROM stevekrouse_com_hits",
const hits = data.rows[0][0];
return new Response(
vtdocs avatar
browserlessPuppeteerExample
@vtdocs
An interactive, runnable TypeScript val by vtdocs
Script
export const browserlessPuppeteerExample = (async () => {
const { PuppeteerDeno } = await import(
"https://deno.land/x/puppeteer@16.2.0/src/deno/Puppeteer.ts"
const puppeteer = new PuppeteerDeno({
productName: "chrome",
const browser = await puppeteer.connect({
browserWSEndpoint:
`wss://chrome.browserless.io?token=${process.env.browserlessKey}`,
const page = await browser.newPage();
await page.goto("https://en.wikipedia.org/wiki/OpenAI");
easrng avatar
nodejsSample
@easrng
// run node.js code in your val
Script
import { nodejs } from "https://esm.town/v/easrng/nodejs";
// run node.js code in your val
export const nodejsSample = (async () => {
const nodeEval = await nodejs();
console.log(await nodeEval("2 + 2"));
console.log(await nodeEval("typeof require"));
yawnxyz avatar
unpaywall
@yawnxyz
// Unpaywall DOI access function
HTTP (deprecated)
const app = new Hono();
const YOUR_EMAIL = "jan@phage.directory";
// Unpaywall DOI access function
async function unpaywallDOI(doi) {
const url = `https://api.unpaywall.org/v2/${doi}?email=${YOUR_EMAIL}`;
const options = {
method: 'GET',
headers: {
'accept': 'application/json',
'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0
stevekrouse avatar
lucia_demo
@stevekrouse
@jsxImportSource npm:hono/jsx
HTTP (deprecated)
/** @jsxImportSource npm:hono/jsx **/
const userTable = "user";
const sessionTable = "session";
const adapter = new ValTownAdapter({ userTable, sessionTable });
export const lucia = new Lucia(adapter, {
getUserAttributes: (attributes) => {
return {
username: attributes.username,
declare module "npm:lucia" {
interface Register {
janpaul123 avatar
valle_tmp_92279722423458817448513814852015
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
const vt = new ValTown({ bearerToken: Deno.env.get("valtown") });
const username = "janpaul123";
const app = new Hono();
const systemPrompt = `The conversation below is your recent interaction with the user.
Your entire response should only be TypeScript.
Your response should start with \`\`\`ts and end with \`\`\`.
Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
Start your response with a comment explaining how your approach will work, what libraries or
API calls you will use, and any tradeoffs you're making. Then write the code in a concise way,
janpaul123 avatar
valle_tmp_3173618096166977554668362851031
@janpaul123
@jsxImportSource https://esm.sh/react
HTTP (deprecated)
/** @jsxImportSource https://esm.sh/react */
const vt = new ValTown({ bearerToken: Deno.env.get("valtown") });
const username = "janpaul123";
const app = new Hono();
const jsxResponse = (jsx) => {
return new Response(renderToString(jsx), { headers: { "Content-Type": "text/html" } });
const systemprompt = `The conversation below is your recent interaction with the user.
Your entire response should only be TypeScript.
Your response should start with \`\`\`ts and end with \`\`\`.
Make an HTTP val (other vals are currently not supported to run, even though we have examples for them).
stevekrouse avatar
chatWithCerebras
@stevekrouse
@jsxImportSource https://esm.sh/react
HTTP
/** @jsxImportSource https://esm.sh/react */
const MODELS = ["llama3.1-8b", "llama3.1-70b"];
function App() {
const [messages, setMessages] = useState<Array<{ role: string; content: string }>>([]);
const [edits, setEdits] = useState<Array<{ id: number; content: string }>>(
const [input, setInput] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [htmlOutput, setHtmlOutput] = useState("");
const [selectedModel, setSelectedModel] = useState(MODELS[0]);
const messagesEndRef = useRef<HTMLDivElement>(null);
pomdtr avatar
jsoninvoice
@pomdtr
@jsxImportSource npm:hono/jsx
HTTP (deprecated)
/** @jsxImportSource npm:hono/jsx */
extractParams,
Invoice,
Language,
schema,
} from "https://esm.town/v/pomdtr/invoice_schema";
const app = new Hono();
const val = extractValInfo(import.meta.url);
app.use(
honoMiddleware({
yawnxyz avatar
ai
@yawnxyz
An http and class wrapper for Vercel's AI SDK Usage: Groq: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a beer joke"&provider=groq&model=llama3-8b-8192 Perplexity: https://yawnxyz-ai.web.val.run/generate?prompt="what's the latest phage directory capsid & tail article about?"&provider=perplexity Mistral: https://yawnxyz-ai.web.val.run/generate?prompt="tell me a joke?"&provider=mistral&model="mistral-small-latest" async function calculateEmbeddings(text) { const url = `https://yawnxyz-ai.web.val.run/generate?embed=true&value=${encodeURIComponent(text)}`; try { const response = await fetch(url); const data = await response.json(); return data; } catch (error) { console.error('Error calculating embeddings:', error); return null; } }
HTTP (deprecated)
An http and class wrapper for Vercel's AI SDK
Usage:
- Groq: `https://yawnxyz-ai.web.val.run/generate?prompt="tell me a beer joke"&provider=groq&model=llama3-8b-8192`
- Perplexity: `https://yawnxyz-ai.web.val.run/generate?prompt="what's the latest phage directory capsid & tail article about?
- Mistral: `https://yawnxyz-ai.web.val.run/generate?prompt="tell me a joke?"&provider=mistral&model="mistral-small-latest"`
async function calculateEmbeddings(text) {
// import { z } from "npm:zod";
// import { nanoid } from 'npm:nanoid';
const URL = "https://yawnxyz-coversheetai.web.val.run"
const taskPrefix = "task::ai:"
pomdtr avatar
indielogin_example
@pomdtr
@jsxImportSource npm:hono/jsx
HTTP (deprecated)
/** @jsxImportSource npm:hono/jsx */
const app = new Hono();
const val = extractValInfo(import.meta.url);
const clientID = new URL("/", val.httpEndpoint).toString();
const redirectURI = new URL("/redirect", val.httpEndpoint).toString();
app.get("/", (c) => {
return c.json("OK");
app.get("/login", (c) => {
const state = crypto.randomUUID();
setCookie(c, "state", state, {
tmcw avatar
happyDomExample
@tmcw
happy-dom Happy-dom is a module that provides a DOM-like abstraction that's pretty popular for test frameworks and server-side rendering, because it's a lot faster and lighter than more full-fledged browser-like options. By default, happy-dom doesn't support Deno , which is the basis for Val Town's runtime, but there's a fork that conveniently swaps out the thing it doesn't support, which is the Node.js vm module. Another way to work with the DOM is to use domino .
Script
# happy-dom
[Happy-dom](https://github.com/capricorn86/happy-dom) is a module that provides a DOM-like abstraction that's pretty popular
Another way to work with the DOM is to use [domino](https://www.val.town/v/tmcw.dominoDomExample).
export let happyDomExample = (async () => {
const { Window } = await import("npm:@zuisong/happy-dom-deno");
const window = new Window({
url: "https://localhost:8080",
width: 1024,
height: 768,
const document = window.document;
andreterron avatar
honoGameTest
@andreterron
An interactive, runnable TypeScript val by andreterron
Script
import { honoHead } from "https://esm.town/v/andreterron/honoHead";
export async function honoGameTest(req: Request) {
const { Hono } = await import("npm:hono");
const { html } = await import("npm:hono/html");
const app = new Hono();
app.get("/", (c) => {
const head = honoHead("Test");
return c.html(html`<div style="background-color: pink;">Hello!</div>`);
return app.fetch(req);
niek avatar
Fetch
@niek
Fetch Template Example template to quickly get started with a backend for Fetch in Framer.
HTTP (deprecated)
# Fetch Template
Example template to quickly get started with a backend for Fetch in Framer.
const app = new Hono();
app.use(cors());
app.get("/", async (c) => {
return c.json({
"name": "Niek Kruse",
"firstName": "Niek",
"avatar": null,
"initials": "NK",
easrng avatar
nodejs
@easrng
An interactive, runnable TypeScript val by easrng
Script
export async function nodejs() {
const token =
(await runVal("easrng.nodejsInternals", {
action: "create",
})) as string;
return async (code) =>
await runVal("easrng.nodejsInternals", {
action: "eval",
token,
code,