• Blog
  • Docs
  • Pricing
  • We’re hiring!
Log inSign up
std

std

utils

Public
Val Town Utilities
Like
6
utils
Home
Code
19
README.md
H
_docs.tsx
H
_tests.ts
H
example.test.ts
H
file.test.ts
file.ts
H
hot-reload.example.tsx
hot-reload.test.ts
hot-reload.ts
index.ts
H
is-main.test.ts
is-main.ts
H
parseImportMeta.test.ts
parseImportMeta.ts
H
serve-file.test.ts
serve-file.ts
H
static.test.ts
static.tsx
test.tsx
Connections
Environment variables
Branches
3
Pull requests
2
Remixes
8
History
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.
Sign up now
Code
/
README.md
Code
/
README.md
Search
4/4/2026
Viewing readonly version of main branch: v255
View latest version
README.md

@std/utils

Standard utility library for Val Town. Provides helpers for reading files, serving static content, parsing val metadata, and testing.

πŸ“– Full API documentation

Installation

import { readFile, serveFile, parseVal, listFiles } from "https://esm.town/v/std/utils/index.ts";

Quick start

// Read a file from your val const content = await readFile("/README.md"); // Serve static files in a Hono app app.get("/assets/*", (c) => serveFile(c.req.path)); // Get the current val's metadata const val = parseVal(import.meta.url); console.log(val.username, val.name);

Exported functions

FunctionDescription
readFileRead raw file contents from your val
readFileTranspiledRead transpiled JS (types stripped) for browser use
listFilesList all files in the current val with metadata
listFilesByPathList files in a specific directory
httpEndpointGet the live HTTP URL for a file
emailAddressGet the email address for an email-trigger file
getValIdGet the current val's UUID
fetchTranspiledJavaScriptFetch transpiled JS from any esm.town URL
serveFileServe a file as an HTTP Response with correct Content-Type
getContentTypeGet MIME type for a file path
staticHTTPServerCreate a static file server (serves /index.html at root)
parseValParse val metadata (username, name, version, branch, links) from import.meta.url
isMainCheck if the current file is the entrypoint
testServerCreate an HTML test runner with pass/fail badges

Architecture

Rendering mermaid diagram...

File overview

FileTypePurpose
index.tsscriptPublic entry point β€” re-exports all utilities
file.tsscriptFile I/O: read, list, transpile, endpoints, email addresses
serve-file.tsscriptHTTP file serving with MIME type detection
parseImportMeta.tsscriptParse import.meta.url into val metadata
is-main.tsscriptEntrypoint detection (import.meta.main replacement)
test.tsxscriptTest runner with HTML output and SVG badges
static.tsxscriptHono-based static file server
_docs.tsxhttpAuto-generated documentation site at utilities.val.run
_tests.tshttpTest suite endpoint
*.test.tshttpPer-module test files

Development

Tests run as HTTP endpoints. Each source file has a corresponding .test.ts file. The _tests.ts file aggregates all tests and serves a badge at /badge.svg.

The _docs.tsx file uses the TypeScript compiler API to extract JSDoc from source files and render them as an HTML documentation site. Return type overrides for SDK types that can't be resolved by the in-memory compiler are hardcoded in RETURN_TYPE_OVERRIDES β€” these may need updating if the @valtown/sdk types change.

FeaturesVersion controlCode intelligenceCLIMCP
Use cases
TeamsAI agentsSlackGTM
DocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
AboutAlternativesPricingBlogNewsletterCareers
We’re hiring!
Brandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Open Source Pledge
Terms of usePrivacy policyAbuse contact
Β© 2026 Val Town, Inc.