VTDocs
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.
app.ts
https://wolf--2355a478f80f47dfa7909b9db90b7b38.web.val.run
Electric is a lightweight static site hosting system built on Hono RPC and Val Town blob store, with
a simple CLI. You can use Electric with your favorite static site generator, and add
electric upload
at the end of your build script.
- Simple File Management: Upload, download, list, and delete files through a RESTful API
- Command Line Interface: Easy-to-use CLI for bulk operations with concurrent uploads
- Authentication: Secure API access with bearer token authentication
- Caching: Optimized content delivery with configurable cache settings
- Val Town Integration: Leverages Val Town's blob storage for reliable file hosting
- Remix this Val by clicking the remix button
- Go to environmental variables, and set
MASTER_BEARER
to some secure code. You can useopenssl rand -base64 32
to generate a cryptographically random one. Make sure to save it. - [OPTIONAL] Set a vanity domain for the static site by going to
backend/app.ts
and choosing a new domain. - Set the
ROOT_URL
environmental variable to that root url. - Set the
STORAGE_PREFIX
to something that describes what the static website is. This is where the files will live.
Now, make sure you have Deno installed locally, and then
# Install the CLI tool deno install -grAf -n=electric https://esm.town/v/wolf/Electric/cli/mod.ts # Upload a directory of static files electric upload ./my-site # List your uploaded files electric list
For all CLI commands, run electric --help
.
The service exposes RESTful endpoints for programmatic access:
GET /api/index
: List all filesPOST /api/index
: Upload a new fileGET /api/index/:path
: Download a specific fileDELETE /api/index/:path
: Delete a file