Search

Results include substring matches and semantically similar vals. Learn more
aleaf avatar
searchArXiV
@aleaf
An interactive, runnable TypeScript val by aleaf
Script
export const searchArXiV = async ({ query = "", start = 0, max_results = 10 }) => {
const { parseStringPromise } = await import("npm:xml2js");
const url = new URL("https://export.arxiv.org/api/query");
url.searchParams.set("search_query", query);
url.searchParams.set("start", start);
url.searchParams.set("max_results", max_results);
const response = await fetch(url.toString());
const text = await response.text();
if (!response.ok) {
throw new Error(text);
lxmrc avatar
TodoApp
@lxmrc
SSR React Mini & SQLite Todo App This Todo App is server rendered and client-hydrated React. This architecture is a lightweight alternative to NextJS, RemixJS, or other React metaframeworks with no compile or build step. The data is saved server-side in Val Town SQLite . SSR React Mini Framework This "framework" is currently 44 lines of code, so it's obviously not a true replacement for NextJS or Remix. The trick is client-side importing the React component that you're server rendering . Val Town is uniquely suited for this trick because it both runs your code server-side and exposes vals as modules importable by the browser. The tricky part is making sure that server-only code doesn't run on the client and vice-versa. For example, because this val colocates the server-side loader and action with the React component we have to be careful to do all server-only imports (ie sqlite) dynamically inside the loader and action , so they only run server-side.
HTTP (deprecated)
# SSR React Mini & SQLite Todo App
This Todo App is server rendered *and* client-hydrated React. This architecture is a lightweight alternative to NextJS, Remix
![demo](https://imagedelivery.net/iHX6Ovru0O7AjmyT5yZRoA/3bbc3a39-9017-4a95-797b-2f205aa57f00/public)
## SSR React Mini Framework
This ["framework"](https://www.val.town/v/stevekrouse/ssr_react_mini) is currently 44 lines of code, so it's obviously not a
The trick is [client-side importing](https://www.val.town/v/stevekrouse/ssr_react_mini?v=53#L30) the React component that you
/** @jsxImportSource https://esm.sh/react */
export async function loader(req: Request) {
const { sqlite } = await import("https://esm.town/v/std/sqlite?v=4");
const [, { columns, rows }] = await sqlite.batch([
stevekrouse avatar
nodeJSDist
@stevekrouse
An interactive, runnable TypeScript val by stevekrouse
HTTP (deprecated)
import LZString from "npm:lz-string";
export async function nodeJSDist(req: Request): Promise<Response> {
let url = new URL(req.url);
if (url.pathname === "/index.tab") {
return new Response(LZString.decompress(nodeJS_dist));
} else if (url.pathname === "/index.json") {
return new Response("Coming soon...");
} else {
return new Response("Not found", { status: 404 });
nbbaier avatar
TanaAPIHelper
@nbbaier
An interactive, runnable TypeScript val by nbbaier
Script
export class TanaAPIHelper {
private endpoint = "https://europe-west1-tagr-prod.cloudfunctions.net/addToNodeV2";
private get schemaNodeId() {
return `SCHEMA`;
private get inboxNodeID() {
return `INBOX`;
private get coreTemplateId() {
return "SYS_T01";
private get attrDefTemplateId() {
return "SYS_T02";
mharris717 avatar
VALLErun
@mharris717
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
HTTP (deprecated)
The actual code for VALL-E: https://www.val.town/v/janpaul123/VALLE
/** @jsxImportSource https://esm.sh/react */
// Set these to your own
const username = "janpaul123";
const tempValsParentFolderId = "4bb7b010-4443-11ef-8642-de64eea55b61";
export default function(
{ username, tempValsParentFolderId }: { username: string; tempValsParentFolderId: string },
const valTownToken = Deno.env.get("valtown");
const vt = new ValTown({ bearerToken: valTownToken });
const app = new Hono();
iamseeley avatar
starterTheme
@iamseeley
🏁 starter theme for hello, resume
Script
## 🏁 starter theme for [hello, resume](https://iamseeley-resumehandler.web.val.run/)
export const starterTheme = {
fontLink: `<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap" rel="stylesheet">`,
styles: `
/* General styles */
body {
padding: 5px;
line-height: 1.6;
color: #333;
text-align: left;
stevekrouse avatar
lucia_middleware_safe
@stevekrouse
Cross-platform safe Lucia-middleware This is a pretty ugly sittuation. It's really a hack around the way @stevekrouse/lucia_middlware was written, but to make it safe to import on the frontend, because it only imports the backend stuff dynamically per request.
Script
# Cross-platform safe Lucia-middleware
This is a pretty ugly sittuation. It's really a hack around the way @stevekrouse/lucia_middlware was written, but to make it
export const luciaMiddleware = (handler) => (async (req) => {
const { luciaMiddleware } = await import("https://esm.town/v/stevekrouse/lucia_middleware");
return luciaMiddleware(handler)(req);
stevekrouse avatar
blobImages
@stevekrouse
Image downsizer and uploader
HTTP (deprecated)
# Image downsizer and uploader
/** @jsxImportSource npm:hono@3/jsx */
function esmTown(url) {
return fetch(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.142.86 Safari/537
}).then(r => r.text());
const app = new Hono();
export default app.fetch;
easrng avatar
rssViewer
@easrng
rss viewer a basic RSS reader
HTTP
# rss viewer
[![Open](https://easrng-button.express.val.run/Open)](https://easrng-rssviewer.express.val.run/)
a basic RSS reader
const { document, Node } = parseHTML(`<!DOCTYPE html>`);
TimeAgo.addDefaultLocale(en);
const timeAgo = new TimeAgo("en");
interface FeedEntry {
id: string;
link?: string;
title?: string;
yawnxyz avatar
lucia_middleware_vanilla
@yawnxyz
Lucia Middleware Import users. Backed by Val Town SQLite. Demo: @stevekrouse/lucia_middleware_demo Initially built by @pomdtr.
HTTP (deprecated)
# Lucia Middleware
Import users. Backed by Val Town SQLite.
Demo: @stevekrouse/lucia_middleware_demo
Initially built by @pomdtr.
// This approach uses the Lucia authentication library with a custom ValTownAdapter.
// It provides signup, login, and logout functionality with session management.
// The main tradeoff is the complexity of setting up Lucia, but it offers robust auth features.
/** @jsxImportSource https://esm.sh/react */
const userTable = "user";
const sessionTable = "session";
webup avatar
getVectorStoreBuilder
@webup
An interactive, runnable TypeScript val by webup
Script
export async function getVectorStoreBuilder(docs: object[], spec: {
type: "memory" | "baas";
provider?: "pinecone" | "milvus";
} = { type: "memory" }, embed: "openai" | "huggingface" = "openai") {
const { cond, matches } = await import("npm:lodash-es");
const builder = await getModelBuilder({
type: "embedding",
provider: embed,
const model = await builder();
const setup = cond([
iamseeley avatar
beigeMandrill
@iamseeley
An interactive, runnable TypeScript val by iamseeley
HTTP (deprecated)
export default async function (req: Request): Promise<Response> {
const { searchParams } = new URL(req.url);
// Default values
const title = searchParams.get('title') || 'Hello from val.town';
const bgColor = searchParams.get('bgColor') || '#e15a24';
const textColor = searchParams.get('textColor') || '#1A202C';
// Create SVG
const svg = `
<svg width="1200" height="630" xmlns="http://www.w3.org/2000/svg">
<defs>
willthereader avatar
smileyPNG
@willthereader
Render a PNG This tiny smiley face is rendered by this val: The image response is cached by the CDN, so make sure to change the image name if you make code changes. Any name with a .png extension will work: https://maxm-smileypng.web.val.run/-.png
HTTP (deprecated)
# Render a PNG
This tiny smiley face is rendered by this val: ![](https://maxm-smileypng.web.val.run/-.png)
The image response is cached by the CDN, so make sure to change the image name if you make code changes. Any name with a `.pn
export const smileyPNG = async (request: Request) => {
const { encode } = await import("https://deno.land/x/pngs/mod.ts");
// Dimensions of the image
const [width, height] = [10, 10];
// Create our PNG canvas
const imageData = new Uint8Array(width * height * 4);
const y = [255, 255, 0, 255]; // Yellow
jamessw avatar
sass
@jamessw
An interactive, runnable TypeScript val by jamessw
Script
interface SassArgs {
input: string;
export async function sass(args: SassArgs) {
const input = args.input || "a {color: #663399}";
const sass = await import("https://jspm.dev/sass");
const res = sass.compileString(input);
if (res.css) {
return res.css;
else {
throw res;
hugenshen avatar
httpHelloWorld
@hugenshen
// This approach creates a PC application with a left-side menu structure as requested.
HTTP
// This approach creates a PC application with a left-side menu structure as requested.
// We'll use React for the UI components and React Router for navigation.
// The server will serve the HTML, and the client-side React application will handle the menu and routing.
/** @jsxImportSource https://esm.sh/react */
const menuStructure = [
name: "产品中心",
subMenu: [
{ name: "产品管理", path: "/product-management" },
name: "元数据市场",
subMenu: [