FeaturesTemplatesShowcaseTownie
AI
BlogDocsPricing
Log inSign up
codemore

codemore

selfDestruct

Remix of peterqliu/selfDestruct
Public
Like
selfDestruct
Home
Code
2
README.md
main.tsx
Branches
1
Pull requests
Remixes
History
Environment variables
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
10/16/2024
README.md

💥

Deletes the val using it, or whatever url is fed it. Handy for sharing single-use scripts without cluttering people's accounts.

If used in an HTTP val, this will run immediately when anyone forks it, making for a zero-click execution as long as ValTown immediately serves a preview of the forked val.

Add this to your code last and then do not run it, or you will lose your work. Recommend first checking that the val owner isn't you, so that only forked copies will self-destruct.

Usage

selfDestruct(import.meta.url)

Returns a promise of successful deletion, though the val would not be around to read it.

Get started with a template:
FeaturesVersion controlCode intelligenceCLI
Use cases
TeamsAI agentsSlackGTM
ExploreDocsShowcaseTemplatesNewestTrendingAPI examplesNPM packages
PricingNewsletterBlogAboutCareersBrandhi@val.townStatus
X (Twitter)
Discord community
GitHub discussions
YouTube channel
Bluesky
Terms of usePrivacy policyAbuse contact
© 2025 Val Town, Inc.