<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: materwelon</title>
    <description>The latest articles on DEV Community by materwelon (@materwelondhruv).</description>
    <link>https://dev.to/materwelondhruv</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3980938%2Fd5ff6f66-146b-4b26-b7da-0975c8a0fdfd.gif</url>
      <title>DEV Community: materwelon</title>
      <link>https://dev.to/materwelondhruv</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/materwelondhruv"/>
    <language>en</language>
    <item>
      <title>Vite • seedcord v0.22.0</title>
      <dc:creator>materwelon</dc:creator>
      <pubDate>Fri, 20 Nov 2026 18:59:26 +0000</pubDate>
      <link>https://dev.to/materwelondhruv/vite-seedcord-v0220-57m5</link>
      <guid>https://dev.to/materwelondhruv/vite-seedcord-v0220-57m5</guid>
      <description>&lt;p&gt;With v0.22, we're bringing Vite to production builds too! &lt;code&gt;seedcord dev&lt;/code&gt; was already using Vite, and now &lt;code&gt;seedcord build&lt;/code&gt; does as well. With Vite 8 (Rolldown), this means faster builds and more consistency between development and production. Previously, production builds were transpiled with TypeScript and their aliases rewritten with &lt;code&gt;tsc-alias&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To upgrade your bot, run your package manager's upgrade command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm update --latest seedcord @seedcord/http
bun update --latest seedcord @seedcord/http
npm install seedcord@latest @seedcord/http@latest
yarn upgrade --latest seedcord @seedcord/http

&lt;span class="c"&gt;# Replace @seedcord/http with your transport, and update any Seedcord plugins you use.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New to seedcord? Scaffold your first bot with our &lt;code&gt;create-seedcord&lt;/code&gt; CLI:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm create seedcord@latest
bun create seedcord@latest
npm init seedcord@latest
yarn create seedcord@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then head over to &lt;a href="https://seedcord.org/guide/first-bot/" rel="noopener noreferrer"&gt;our first bot guide&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Curious what seedcord does and why? &lt;a href="https://seedcord.org/guide/" rel="noopener noreferrer"&gt;Start here!&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here are some things from this release we'd like to highlight:&lt;/p&gt;




&lt;h2&gt;
  
  
  Static builds with Vite &amp;amp; Vite plugin support
&lt;/h2&gt;

&lt;p&gt;As mentioned above, this release features Vite builds for production (&lt;code&gt;seedcord build&lt;/code&gt;). Before, only &lt;code&gt;seedcord dev&lt;/code&gt; was using Vite, which meant we had two different build paths for dev and prod. As an additional pain point, the previous production build was more of a "transpilation": at runtime, your modules were still being dynamically read from the filesystem instead of statically imported.&lt;/p&gt;

&lt;p&gt;By moving to Vite and unifying dev and build, we now have consistent parsing behaviour across dev and prod, as well as reduced complexity, and no more of that runtime module importing behaviour. &lt;em&gt;Hooray for all!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Because we have now adopted Vite entirely, you can also use your own Vite plugins in the seedcord config file, like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'seedcord/config'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'vite-plugin-foo'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
    &lt;span class="n"&gt;vitePlugins&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure that any environment-aware plugins target the &lt;code&gt;seedcord&lt;/code&gt; environment, since that's the environment that seedcord is set up in.&lt;/p&gt;

&lt;p&gt;You'll find more information about using Vite plugins, and when to use seedcord plugins vs Vite plugins, on &lt;a href="https://seedcord.org/guide/build/vite-plugins/" rel="noopener noreferrer"&gt;this guide page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;This upgrade solves our bundling problems and lets us do something else that's pretty cool:&lt;/p&gt;




&lt;h2&gt;
  
  
  Edge bots
&lt;/h2&gt;

&lt;p&gt;You can now write HTTP bots that run on the edge (Cloudflare Workers)! Previously, the option to run bots on Workers wasn't functional, and you only had the option to run it on a server runtime like Node. With this release, you can now write bots using seedcord that build as Cloudflare Workers. These bots use Discord's Interactions webhook capability to allow your bot to receive certain events as a webhook call to your bot instead of via the Gateway, and when you're done, you can deploy them to the Cloudflare Workers platform.&lt;/p&gt;

&lt;p&gt;To get started, run either of these commands (depending on your package manager):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm create seedcord
bun create seedcord
npm init seedcord
yarn create seedcord
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then select the HTTP bots option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frzgcwp7wguw2ljkhk3cl.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Frzgcwp7wguw2ljkhk3cl.webp" alt="Bot transport options" width="800" height="127"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And finally select Cloudflare Workers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz0e93if0zwj6yvsionrh.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fz0e93if0zwj6yvsionrh.webp" alt="HTTP bot runtime selection" width="800" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure to fill in the remaining details as requested, and then your bot should now be scaffolded.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: The runtime option will only appear for HTTP bots.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now, &lt;code&gt;cd&lt;/code&gt; into your project directory:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; edge-bot &lt;span class="c"&gt;# replace with your bot's directory&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And run &lt;code&gt;seedcord dev&lt;/code&gt; with your package manager. Your bot will now be running and ready for you to iterate on. Edit a relevant file, and your bot will have hot module replacement (HMR) activating to swap out the module you just edited, faster than you can blink!&lt;/p&gt;

&lt;p&gt;In dev, the bot is running inside &lt;code&gt;workerd&lt;/code&gt;, the same runtime used by Cloudflare Workers. This ensures there are few differences between your local testing and the production runtime. This is possible thanks to us moving to use Vite for both dev and build, allowing us to fully utilise the &lt;a href="https://vite.dev/guide/api-environment" rel="noopener noreferrer"&gt;Vite Environment API&lt;/a&gt;. This system allows us to coordinate dev and build in a separate runtime like this and accurately map the &lt;code&gt;seedcord&lt;/code&gt; application. Huge thanks to the Vite team for making this!&lt;/p&gt;

&lt;p&gt;Before your first deploy, log in to Cloudflare and deploy your commands. The build reads their IDs from Discord:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec&lt;/span&gt; cf auth login
pnpm &lt;span class="nb"&gt;exec&lt;/span&gt; seedcord commands deploy
pnpm build
pnpm &lt;span class="nb"&gt;exec&lt;/span&gt; cf deploy --prebuilt --secrets-file .secrets.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Make sure &lt;code&gt;DISCORD_BOT_TOKEN&lt;/code&gt; is available in your shell or &lt;code&gt;.env&lt;/code&gt; when you build. For the first deploy, put every secret declared in &lt;code&gt;cloudflare.config.ts&lt;/code&gt; in &lt;code&gt;.secrets.env&lt;/code&gt;, not just the bot token. Keep that file out of git. After the first deploy, the scaffold's &lt;code&gt;deploy&lt;/code&gt; script builds and deploys without the secrets file. With Bun, use &lt;code&gt;bunx&lt;/code&gt; for each &lt;code&gt;pnpm exec&lt;/code&gt; command and &lt;code&gt;bun run build&lt;/code&gt; for &lt;code&gt;pnpm build&lt;/code&gt;. And voila! Now you've got a seedcord edge bot deployed to Cloudflare.&lt;/p&gt;

&lt;p&gt;Set Discord's &lt;strong&gt;Interactions Endpoint URL&lt;/strong&gt; to your Worker URL in the developer portal.&lt;/p&gt;

&lt;p&gt;Read up on this in &lt;a href="https://seedcord.org/guide/build/workers/" rel="noopener noreferrer"&gt;the guide page&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Command management via CLI
&lt;/h2&gt;

&lt;p&gt;If you've ever deployed any bot to Discord (not just seedcord ones), you'll know that command management is a bit of a pain. There's no way to delete your registered commands in Discord's developer portal, whether they're global or guild commands.&lt;/p&gt;

&lt;p&gt;That pain is no more for seedcord bots! Starting with this version, the framework CLI now has a &lt;code&gt;commands&lt;/code&gt; subcommand, which is your home for managing command deployments.&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;seedcord commands&lt;/code&gt; gives you the following options:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4w3o5e3sinsdr6a8qmbo.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F4w3o5e3sinsdr6a8qmbo.webp" alt="Command manager" width="800" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Deploy the commands in your code&lt;/strong&gt; - seedcord will read your code, compile a list of commands, and deploy them according to how you configured your command (&lt;code&gt;guild&lt;/code&gt; commands are deployed to a server of your choosing, &lt;code&gt;global&lt;/code&gt; commands are deployed to the bot itself).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;List the commands Discord has&lt;/strong&gt; - Lists the commands your bot has deployed globally or in servers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete guild commands that duplicate a global command&lt;/strong&gt; - Removes guild commands that share a name with a global command.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Delete every command globally or in guilds&lt;/strong&gt; - Deletes every command your bot has registered, globally and/or in guilds. &lt;em&gt;&lt;strong&gt;This is very destructive. Make sure you've selected the right bot and, if applicable, the right guild!&lt;/strong&gt;&lt;/em&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these can also be accessed with subcommands:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;deploy [options]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;list [options]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;clean [options]&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;purge [options]&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows you to have simplified command management while building and maintaining your bot with seedcord!&lt;/p&gt;

&lt;p&gt;To learn more about the subcommands, visit &lt;a href="https://seedcord.org/guide/tooling/commands/" rel="noopener noreferrer"&gt;this guide page&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Library mode
&lt;/h2&gt;

&lt;p&gt;seedcord bots can be built (and published) as libraries! This allows you to write your bots using the framework, and export them for use as part of a larger application. This will be most useful to bots on HTTP transports, as you can easily integrate them into backend frameworks like Hono, H3, Elysia, or even full-stack frameworks like Nitro, TanStack Start, Astro, and more.&lt;/p&gt;

&lt;p&gt;To build library bots, omit &lt;code&gt;build.start&lt;/code&gt; from your seedcord config:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;defineConfig&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'seedcord/config'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nf"&gt;defineConfig&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'./src'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'./bot.ts'&lt;/span&gt;
    &lt;span class="c1"&gt;// do not set build.start&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now, your bot will be packaged as a library, ready for you to reuse it elsewhere.&lt;/p&gt;

&lt;p&gt;To use library bots, simply import them from their bot entrypoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="n"&gt;bot&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="s1"&gt;'@mypkg/bot'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Change the entrypoint to your bot package entrypoint&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HTTP bots comply with the &lt;code&gt;export default { fetch }&lt;/code&gt; standard used by Cloudflare Workers, Bun, Hono, H3, Elysia, and more. This means that you can simply pass in one &lt;code&gt;Request&lt;/code&gt; object and get the &lt;code&gt;Response&lt;/code&gt; from the bot. In a Node server, call &lt;code&gt;start()&lt;/code&gt; before passing requests to &lt;code&gt;fetch()&lt;/code&gt;; on Workers, the first request starts the bot. The &lt;a href="https://seedcord.org/guide/build/embed/" rel="noopener noreferrer"&gt;embedding guide&lt;/a&gt; has an example.&lt;/p&gt;

&lt;p&gt;For Gateway bots, start them using the &lt;code&gt;start&lt;/code&gt; method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;bot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your bot can now be used like a library in another app.&lt;/p&gt;

&lt;p&gt;See &lt;a href="https://seedcord.org/guide/build/package/" rel="noopener noreferrer"&gt;the guide&lt;/a&gt; to learn more. There's also &lt;a href="https://seedcord.org/guide/build/embed/" rel="noopener noreferrer"&gt;a guide page on integrating with web servers&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Session lock files
&lt;/h2&gt;

&lt;p&gt;Did you ever start a dev server and forget about it? Well, as a small new addition to this update, we've added a session lock file.&lt;/p&gt;

&lt;p&gt;When you start a dev session, a lock file records the Discord application ID. If another dev session starts with the same application ID, the CLI shows the first session's folder, process id, start time, and lock file path. Press &lt;code&gt;q&lt;/code&gt; in that session to stop it, or remove the lock if the session has already stopped.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkusboqc93sn79ry3kdsi.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fkusboqc93sn79ry3kdsi.webp" alt="lockfile dev error" width="800" height="309"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This will not trigger if bots are using different applications, so it won't get in your way if you are developing several distinct bots.&lt;/p&gt;




&lt;h2&gt;
  
  
  Other fixes and improvements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;~40 bug fixes were included in this release&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;create-seedcord&lt;/code&gt; got a refreshed look, asks if you want to install dependencies and initialize a git repo, and comes with a sample uptime plugin.&lt;/li&gt;
&lt;li&gt;The TUI is now more responsive for narrower screens (such as mobile or split screen on computers)&lt;/li&gt;
&lt;li&gt;Certain layout and filter preferences for dev sessions are now saved across sessions.&lt;/li&gt;
&lt;li&gt;The bot health check was revamped and now correctly says ready when the bot is actually ready for gateway and HTTP bots running on Node.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For the rest of the release information, &lt;a href="https://github.com/seedcord/seedcord/releases/tag/release-2026.10.25" rel="noopener noreferrer"&gt;read the release changelog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Join our &lt;a href="https://seedcord.org/chat" rel="noopener noreferrer"&gt;Discord server&lt;/a&gt; to chat with others about seedcord!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First posted on &lt;a href="https://seedcord.org/blog/release-v0-22/" rel="noopener noreferrer"&gt;the seedcord blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>vite</category>
      <category>typescript</category>
      <category>discord</category>
      <category>node</category>
    </item>
    <item>
      <title>seedcord v0.23 release</title>
      <dc:creator>materwelon</dc:creator>
      <pubDate>Fri, 20 Nov 2026 18:20:09 +0000</pubDate>
      <link>https://dev.to/materwelondhruv/seedcord-v023-release-11g6</link>
      <guid>https://dev.to/materwelondhruv/seedcord-v023-release-11g6</guid>
      <description>&lt;p&gt;That's the bill for this release. 78 changes since v0.22, and 20 of them are breaking, so your bot is paying for some of it. It's less scary than it looks though. More on that at the end.&lt;/p&gt;

&lt;p&gt;This all started as a short list of things to fix before the release, and it kept growing. One PR ended up titled "&lt;code&gt;feat: refactor? chore? fix? god pr&lt;/code&gt;", which tells you how that went.&lt;/p&gt;

&lt;p&gt;Here's the good stuff.&lt;/p&gt;




&lt;h2&gt;
  
  
  You can ask the guide questions now
&lt;/h2&gt;

&lt;p&gt;Docs search only works when you already know the word the docs use. You want to stop people spamming a command, and the page you need is called Cooldowns. If nobody ever told you that's what it's called, good luck.&lt;/p&gt;

&lt;p&gt;So now you can type what you'd ask a person. Press &lt;code&gt;Cmd+K&lt;/code&gt; or &lt;code&gt;/&lt;/code&gt; on &lt;a href="https://seedcord.org/guide/" rel="noopener noreferrer"&gt;the guide&lt;/a&gt; and try it. These are real searches, with the top result each one got:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;how do i stop people from spamming a command  👉🏻  Cooldowns
how do i know which button someone clicked    👉🏻  Buttons
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Text matches show up right away under &lt;strong&gt;Matches&lt;/strong&gt;. Once you stop typing, your question goes to Cloudflare Workers AI, which turns it into a vector with EmbeddingGemma. The guide sections closest in meaning come back under &lt;strong&gt;Related&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I think this matters more than anything else on &lt;em&gt;the bill of changes&lt;/em&gt; above. When you're looking something up you're usually stuck, and you don't know the right word yet.&lt;/p&gt;

&lt;p&gt;You can run the same search from a terminal too, even outside a project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm &lt;span class="nb"&gt;exec&lt;/span&gt; seedcord ask how &lt;span class="k"&gt;do&lt;/span&gt; i stop someone spamming a &lt;span class="nb"&gt;command&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints the matching pages with a link to each section. It also takes a pasted error, or an error code like &lt;code&gt;3116&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;This one's really useful for coding agents. I found that out working on a bot of my own. The agent hand-wrote pagination and refusal replies, and both of those ship with seedcord. &lt;code&gt;tc&lt;/code&gt; and lint pass either way, so nothing told it otherwise. Now a new project has an &lt;code&gt;ask&lt;/code&gt; script, and its &lt;code&gt;AGENTS.md&lt;/code&gt; tells agents to search the guide before they hand-write something. Without a terminal, the command links each page's Markdown copy, so an agent can read the page directly. &lt;a href="https://seedcord.org/guide/tooling/ask/" rel="noopener noreferrer"&gt;Here's some more about it&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And a nice lil feature for you keyboard people out there: shortcuts in the guide!&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Left and right change pages&lt;/li&gt;
&lt;li&gt;Shift plus left or right changes tabs&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;j&lt;/code&gt; and &lt;code&gt;k&lt;/code&gt; move between sections&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;y&lt;/code&gt; copies a link to the section you're on&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;s&lt;/code&gt; switches sites&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;?&lt;/code&gt; shows all these shortcuts&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  We launched a bot
&lt;/h2&gt;

&lt;p&gt;Meet seed, our own Discord bot. It's built with seedcord, it runs on Cloudflare Workers, and you can &lt;a href="https://discord.com/oauth2/authorize?client_id=1195232619718254663" rel="noopener noreferrer"&gt;add it to a server or install it on your account&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;It brings that same search into Discord, so you can look stuff up without leaving the conversation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;/search guide&lt;/code&gt; takes a question in your own words.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/search docs&lt;/code&gt; finds a symbol by name. Set &lt;code&gt;prerelease&lt;/code&gt; to search the &lt;code&gt;@next&lt;/code&gt; versions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Answer with docs&lt;/strong&gt; is a right-click on someone's message. You pick a guide section that answers it, and seed posts the link and mentions them.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;/versions&lt;/code&gt; shows the latest and next version of each seedcord package.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both &lt;code&gt;/search&lt;/code&gt; commands reply only to you by default. Set &lt;code&gt;public&lt;/code&gt; when everyone in the channel should see the answer.&lt;/p&gt;

&lt;p&gt;There's also some nice emoji utility built into the bot, and we'll continue adding helpful features like this over time.&lt;/p&gt;




&lt;h2&gt;
  
  
  A key-value store
&lt;/h2&gt;

&lt;p&gt;Bots have to remember stuff, like a member's timezone or a reminder due tomorrow. Most of us start with a &lt;code&gt;Map&lt;/code&gt; at the top of a file, and it's empty again the moment the bot restarts.&lt;/p&gt;

&lt;p&gt;Every bot now has &lt;code&gt;core.kv&lt;/code&gt;. You ask it for a collection, then read and write records by id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/handlers/Timezone.ts&lt;/span&gt;
&lt;span class="nd"&gt;@SlashRoute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'timezone'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Timezone&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;SlashHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'timezone'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;preferences&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;core&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kv&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;collection&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Preferences&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'preferences'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;preferences&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;set&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;timezone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'zone'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;updatedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nb"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'Saved.'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Leave &lt;code&gt;kv&lt;/code&gt; out of your config and records stay in memory. To keep them through a restart, pass a driver:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// src/bot.ts&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;seedcord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Seedcord&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;kv&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;KeyvDriver&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Keyv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;KeyvSqlite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'sqlite://./kv.sqlite'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;KeyvDriver&lt;/code&gt; and &lt;code&gt;UnstorageDriver&lt;/code&gt; wrap those two libraries, so you get SQLite, Redis, Postgres, the filesystem, D1 on Workers, and more. You can also write your own driver.&lt;/p&gt;

&lt;p&gt;Records go through JSON, and the types know that. If your record holds a &lt;code&gt;Set&lt;/code&gt; or a &lt;code&gt;Map&lt;/code&gt;, the &lt;code&gt;collection()&lt;/code&gt; call doesn't compile. A &lt;code&gt;Date&lt;/code&gt; reads back as a &lt;code&gt;string&lt;/code&gt;, and &lt;code&gt;get&lt;/code&gt; shows it that way. Plugins read the same store through &lt;code&gt;this.kv&lt;/code&gt;, and the rate limiter keeps its counts there too.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seedcord.org/guide/built-ins/" rel="noopener noreferrer"&gt;The guide page&lt;/a&gt; has the rest, like records that expire.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;seedcord make&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;I've started way too many buttons by copying the last one, renaming everything, and then fixing the import path because the copy was one folder deeper. Then I'd do it all again for the handler.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;seedcord make&lt;/code&gt; writes those files from templates that you keep in your project. A template is a folder of &lt;a href="https://handlebarsjs.com/guide/" rel="noopener noreferrer"&gt;Handlebars&lt;/a&gt; files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;templates/
└─ Button/
   ├─ components/
   │  └─ {{pascal name}}.ts.hbs
   └─ handlers/
      └─ {{pascal name}}.ts.hbs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You pick &lt;code&gt;Button&lt;/code&gt; and type &lt;code&gt;tickets/Appeal&lt;/code&gt; as the name. It then asks for each value the templates read, and writes both files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/components/tickets/Appeal.ts
src/handlers/tickets/Appeal.ts
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;New projects start with templates for a slash command, a button, a select menu, a modal, and on gateway an event. Installed plugins can ship templates too. &lt;a href="https://seedcord.org/guide/tooling/make/" rel="noopener noreferrer"&gt;Here's how to write your own&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  Plugins can write types now
&lt;/h2&gt;

&lt;p&gt;Say your plugin translates messages, and a bot calls &lt;code&gt;t('greet')&lt;/code&gt;. You wrote that plugin before any bot existed, so all it can type is &lt;code&gt;string&lt;/code&gt;. A typo only shows up when a user sees the wrong message.&lt;/p&gt;

&lt;p&gt;Plugins can now define &lt;code&gt;codegen()&lt;/code&gt;. Whatever it returns ends up in the bot's generated types, built from that bot's own files:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. your codegen() returns a value
   { messages: { greet: true, bye: true } }

2. seedcord codegen writes it as a type into the bot's seedcord-gen.ts
   'seedcord-locales': { messages: { bye: true; greet: true } }

3. your plugin reads it back with Generated&amp;lt;typeof Locales&amp;gt;['messages']
   { bye: true; greet: true }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Mongoose and Kysely plugins use this already, so you can delete the &lt;code&gt;declare module&lt;/code&gt; blocks that list your services.&lt;/p&gt;

&lt;p&gt;Two more things came with it. &lt;code&gt;seedcord dev&lt;/code&gt; has a &lt;code&gt;g&lt;/code&gt; key that runs codegen without restarting your bot. The generated file is also &lt;code&gt;seedcord-gen.ts&lt;/code&gt; now, because &lt;code&gt;skipLibCheck&lt;/code&gt; skipped the old &lt;code&gt;.d.ts&lt;/code&gt;, and a stale row in there quietly turned into &lt;code&gt;any&lt;/code&gt;. Now &lt;code&gt;tc&lt;/code&gt; reports it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://seedcord.org/guide/writing-plugins/codegen/" rel="noopener noreferrer"&gt;Writing types from codegen&lt;/a&gt; walks through a whole plugin.&lt;/p&gt;




&lt;h2&gt;
  
  
  Smaller things I really like
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;this.user&lt;/code&gt;&lt;/strong&gt; is on every interaction handler and middleware. On http in a server, &lt;code&gt;this.event.user&lt;/code&gt; is undefined and you had to go through &lt;code&gt;member.user&lt;/code&gt;. Now you don't have to think about it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;this.route&lt;/code&gt;&lt;/strong&gt; works on event handlers and on event and interaction middleware too, the same as interaction handlers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;this.match()&lt;/code&gt; returns what its cases return&lt;/strong&gt;, including async ones:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;outcome&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;ban&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;banned&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;kick&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;notified&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;outcome&lt;/code&gt; is a union of both shapes. Pass &lt;code&gt;this.match&amp;lt;string&amp;gt;()&lt;/code&gt; if you want every case to return one type, and TypeScript reports the case that doesn't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One subscriber can listen to several keys:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'levelUp'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'levelReset'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;LevelLog&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Subscriber&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="s1"&gt;'levelUp'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="s1"&gt;'levelReset'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;levelUp&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sb"&gt;`reached ${data.level}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;levelReset&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s1"&gt;'was reset'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;code&gt;MentionPrefix&lt;/code&gt;&lt;/strong&gt; is a new gateway gate for commands like &lt;code&gt;@bot ping&lt;/code&gt;. Discord sends the full text of a message that mentions your bot, even without the Message Content intent, so this gets you message commands without that intent:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Gated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;IgnoreBots&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;MentionPrefix&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@RegisterEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nc"&gt;Events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MessageCreate&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Mentioned&lt;/span&gt; &lt;span class="k"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;EventHandler&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Events&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;MessageCreate&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;event&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sb"&gt;`hey ${message.author.displayName}`&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And finally, &lt;strong&gt;replies can now take raw component json&lt;/strong&gt; next to builders, like &lt;code&gt;{ type: 10, content: 'hi' }&lt;/code&gt;. That means you can use libraries like &lt;code&gt;@dressed/react&lt;/code&gt; and write your components in &lt;code&gt;.tsx&lt;/code&gt; files!&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;seedcord dev&lt;/code&gt; without a terminal
&lt;/h2&gt;

&lt;p&gt;When stdin or stdout is a pipe, or &lt;code&gt;CI&lt;/code&gt; is set, &lt;code&gt;seedcord dev&lt;/code&gt; skips the TUI and prints each log line as JSON. You can drive it by writing lines like &lt;code&gt;{"do":"restart"}&lt;/code&gt; or &lt;code&gt;{"do":"codegen"}&lt;/code&gt; to its stdin.&lt;/p&gt;

&lt;p&gt;That means a script, a container, or a coding agent can run your bot properly. A new project's &lt;code&gt;AGENTS.md&lt;/code&gt; now tells an agent to do exactly that, then ask you to run the command in Discord. I test features on real bots this way all the time. &lt;a href="https://seedcord.org/guide/tooling/dev/" rel="noopener noreferrer"&gt;The dev page&lt;/a&gt; lists every command.&lt;/p&gt;




&lt;h2&gt;
  
  
  ~40 fixes
&lt;/h2&gt;

&lt;p&gt;Way too many to list, so here are a few you might have hit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A refused Discord login, like a bad token or disallowed intents, used to sit through the whole 10 second startup timeout. Startup now fails right away with Discord's reason.&lt;/li&gt;
&lt;li&gt;Moving a handler to a new file in &lt;code&gt;seedcord dev&lt;/code&gt; left its route without a handler until you restarted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;seedcord dev&lt;/code&gt; could register a new command twice.&lt;/li&gt;
&lt;li&gt;An autocomplete handler that threw could leave Discord without a response.&lt;/li&gt;
&lt;li&gt;Handlers could read &lt;code&gt;Emojis&lt;/code&gt; before startup filled it, if an interaction came in right after login.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That god PR from earlier added 3 features and fixed 5 bugs, and it finished at +3,262 / -3,250. I'm very proud of those 12 lines.&lt;/p&gt;




&lt;h2&gt;
  
  
  Updating
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pnpm update --latest seedcord @seedcord/gateway &lt;span class="c"&gt;# or @seedcord/http&lt;/span&gt;
pnpm &lt;span class="nb"&gt;exec&lt;/span&gt; seedcord codegen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Update any seedcord plugins you use too. Now, those 20 breaking changes. Most of them only matter if you use that exact API, and your compiler points right at those. Three are worth knowing up front:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;seedcord-gen.d.ts&lt;/code&gt; is now &lt;code&gt;seedcord-gen.ts&lt;/code&gt;. Delete the old file, run codegen once, and rename it in your eslint ignores, &lt;code&gt;.prettierignore&lt;/code&gt;, &lt;code&gt;.gitattributes&lt;/code&gt;, and editor settings.&lt;/li&gt;
&lt;li&gt;Handlers on the same event now run at the same time. Nothing warns you about this one. If one handler reads what another one writes, it can get old values, so make sure to check for that.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Paginator&lt;/code&gt; now sends an ephemeral first page by default. Nothing warns you about this one either. Pass &lt;code&gt;ephemeral: false&lt;/code&gt; to keep a list public.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://github.com/seedcord/seedcord/releases/tag/release-2026.11.04" rel="noopener noreferrer"&gt;The changelog&lt;/a&gt; has everything else.&lt;/p&gt;




&lt;p&gt;Also thanks to &lt;a href="https://github.com/lunaradev1" rel="noopener noreferrer"&gt;lunaradev1&lt;/a&gt;, &lt;a href="https://github.com/KTrain5169" rel="noopener noreferrer"&gt;KTrain5169&lt;/a&gt;, and &lt;a href="https://github.com/SerenModz21" rel="noopener noreferrer"&gt;SerenModz21&lt;/a&gt; for their help on this release!&lt;/p&gt;

&lt;p&gt;New to seedcord? &lt;a href="https://seedcord.org/guide/" rel="noopener noreferrer"&gt;Start here&lt;/a&gt;. Come say hi in &lt;a href="https://seedcord.org/chat" rel="noopener noreferrer"&gt;the Discord server&lt;/a&gt; too.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;First posted on &lt;a href="https://seedcord.org/blog/release-v0-23/" rel="noopener noreferrer"&gt;the seedcord blog&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>discord</category>
      <category>typescript</category>
      <category>vite</category>
      <category>programming</category>
    </item>
    <item>
      <title>Reading typed config from .env in TypeScript</title>
      <dc:creator>materwelon</dc:creator>
      <pubDate>Fri, 12 Jun 2026 15:00:03 +0000</pubDate>
      <link>https://dev.to/materwelondhruv/reading-typed-config-from-env-in-typescript-34cb</link>
      <guid>https://dev.to/materwelondhruv/reading-typed-config-from-env-in-typescript-34cb</guid>
      <description>&lt;p&gt;&lt;code&gt;Number(process.env.PORT) || 3000&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;That line shows up in a lot of config files, and it has two bugs hiding in it.&lt;/p&gt;

&lt;p&gt;Misspell &lt;code&gt;PORT&lt;/code&gt; in your &lt;code&gt;.env&lt;/code&gt; and you don't get an error, you get &lt;code&gt;3000&lt;/code&gt;, and you find out in production. Want to set &lt;code&gt;PORT=0&lt;/code&gt; on purpose? You can't: &lt;code&gt;Number('0') || 3000&lt;/code&gt; is &lt;code&gt;3000&lt;/code&gt; too. The &lt;code&gt;|| fallback&lt;/code&gt; can't tell "missing" from "zero," and &lt;code&gt;process.env&lt;/code&gt; hands you &lt;code&gt;string | undefined&lt;/code&gt; regardless, so every read sits one coercion away from a quiet bug.&lt;/p&gt;

&lt;p&gt;I got tired of writing that coercion by hand and keeping it correct, so I built envapt. On Node, Bun, and Deno it reads &lt;code&gt;process.env&lt;/code&gt; and your &lt;code&gt;.env&lt;/code&gt; files; off Node the source is pluggable, so the same reads work on Cloudflare Workers and in the browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  The typed read
&lt;/h2&gt;

&lt;p&gt;Here's the same port, read so the fallback only fires when the value is actually missing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number, not string | undefined&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;debug&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBoolean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DEBUG&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// 1/yes/true/on -&amp;gt; true&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;getNumber&lt;/code&gt; returns &lt;code&gt;number&lt;/code&gt;. &lt;code&gt;PORT=0&lt;/code&gt; reads as &lt;code&gt;0&lt;/code&gt;. A typo in &lt;code&gt;PORT&lt;/code&gt; is unparseable, so it takes the fallback, but &lt;code&gt;0&lt;/code&gt; is a perfectly good number and keeps it. The &lt;code&gt;Number(x) || default&lt;/code&gt; trap is gone because there's no &lt;code&gt;||&lt;/code&gt; deciding what counts as empty.&lt;/p&gt;

&lt;p&gt;The fallback also does something to the type. Passing one strips &lt;code&gt;undefined&lt;/code&gt; from the return, so nothing downstream needs a &lt;code&gt;?? 3000&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;withFallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// withFallback: number&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;noFallback&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// noFallback: number | undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Leave the fallback off and you get &lt;code&gt;number | undefined&lt;/code&gt;. The type makes you handle the missing case instead of letting you forget. And &lt;code&gt;getBoolean&lt;/code&gt; reads &lt;code&gt;1&lt;/code&gt;, &lt;code&gt;yes&lt;/code&gt;, &lt;code&gt;true&lt;/code&gt;, &lt;code&gt;on&lt;/code&gt; as true and &lt;code&gt;0&lt;/code&gt;, &lt;code&gt;no&lt;/code&gt;, &lt;code&gt;false&lt;/code&gt;, &lt;code&gt;off&lt;/code&gt; as false, case-insensitively, so &lt;code&gt;DEBUG=1&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt; and not the silent &lt;code&gt;false&lt;/code&gt; that &lt;code&gt;=== 'true'&lt;/code&gt; gives you.&lt;/p&gt;

&lt;h2&gt;
  
  
  The shapes that aren't primitives
&lt;/h2&gt;

&lt;p&gt;Most config isn't a bare number. It's a URL, a comma list, a JSON blob, a timeout. &lt;code&gt;getUsing&lt;/code&gt; takes a converter token and hands back the matching type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiUrl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API_URL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// URL | undefined&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;origins&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ALLOWED_ORIGINS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;array&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Url&lt;/span&gt; &lt;span class="p"&gt;}));&lt;/span&gt; &lt;span class="c1"&gt;// URL[] | undefined&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ttl&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CACHE_TTL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;5m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// "5m" -&amp;gt; 300000 (ms); number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Converters.Url&lt;/code&gt; runs the value through &lt;code&gt;new URL&lt;/code&gt;, so a non-absolute URL takes the fallback instead of slipping through as a string. &lt;code&gt;Converters.array({ of: Converters.Url })&lt;/code&gt; splits on the delimiter and converts each element, so the type is &lt;code&gt;URL[]&lt;/code&gt;, not the &lt;code&gt;string[]&lt;/code&gt; you'd &lt;code&gt;.split(',')&lt;/code&gt; your way to. &lt;code&gt;Converters.Time&lt;/code&gt; reads &lt;code&gt;5m&lt;/code&gt; and returns &lt;code&gt;300000&lt;/code&gt;, which means a timeout in your &lt;code&gt;.env&lt;/code&gt; reads the way you'd write it in code rather than as a pile of zeroes you have to count.&lt;/p&gt;

&lt;p&gt;The built-in tokens cover number, integer, float, boolean, bigint, symbol, JSON, URL, RegExp, Date, duration, and arrays. When none of them fit, &lt;code&gt;getWith&lt;/code&gt; takes a plain &lt;code&gt;(raw, fallback) =&amp;gt; T&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;toBytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parseInt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/gb$/i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e9&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/mb$/i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sr"&gt;/kb$/i&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="nx"&gt;e3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// MAX_BODY=10mb&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;maxBody&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MAX_BODY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;toBytes&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number | undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most typed-env libraries ask you to learn their schema. envapt doesn't have one.&lt;/p&gt;

&lt;p&gt;If your code already validates things with zod (or valibot, or arktype), hand that schema to envapt and it uses it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;coerce&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;number&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;int&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1024&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; &lt;span class="c1"&gt;// number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;t3-env and znv do this job too, and do it well, but they're built on zod: the validator is the dependency. envapt uses the Standard Schema interface instead, so which validator you bring is your call, and envapt itself adds nothing to your lockfile.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;parse&lt;/code&gt; runs the value through the schema and returns whatever the schema outputs, typed. A bad &lt;code&gt;PORT&lt;/code&gt; throws on the &lt;code&gt;parse&lt;/code&gt; line with the validator's own message, not a &lt;code&gt;NaN&lt;/code&gt; that some later arithmetic turns into garbage. A third argument is an optional fallback, returned as-is on a missing value, so it has to already satisfy the type because the schema never sees it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timeout&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;TIMEOUT_MS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;coerce&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;number&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt; &lt;span class="mi"&gt;30000&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// number&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  If you'd rather have a config class
&lt;/h2&gt;

&lt;p&gt;The same reads bind to a class field with a decorator. The field is declared with &lt;code&gt;declare&lt;/code&gt; and no initializer, and you need &lt;code&gt;experimentalDecorators&lt;/code&gt; in your &lt;code&gt;tsconfig.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Envapt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;converter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nb"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;fallback&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Envapt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;LOG_LEVEL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;schema&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;z&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;enum&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;debug&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;info&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;logLevel&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;debug&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;info&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;warn&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;declare&lt;/code&gt; and the missing initializer are load-bearing. A real field declaration under &lt;code&gt;useDefineForClassFields&lt;/code&gt; emits a constructor assignment that overwrites the decorator's getter with &lt;code&gt;undefined&lt;/code&gt;, so the property reads back as nothing. &lt;code&gt;declare&lt;/code&gt; tells the compiler the field exists without emitting that assignment. For the common types there's sugar that takes the key and an optional fallback:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Config&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;EnvNum&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;PORT&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;3000&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;EnvUrl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;APP_URL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http://localhost:3000&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;appUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;EnvTime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CACHE_TTL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;5m&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;ttl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ms&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How I actually use it
&lt;/h2&gt;

&lt;p&gt;In my bot framework, seedcord, which already leans on decorators, the Discord token binds to the &lt;code&gt;Bot&lt;/code&gt; class that uses it, validated by a converter right at the binding:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;validateDiscordToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;?.&lt;/span&gt;&lt;span class="nf"&gt;trim&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DISCORD_BOT_TOKEN is missing&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="sr"&gt;/^&lt;/span&gt;&lt;span class="se"&gt;[\w&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;]{24,}\.[\w&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;]{6,}\.[\w&lt;/span&gt;&lt;span class="sr"&gt;-&lt;/span&gt;&lt;span class="se"&gt;]{27,}&lt;/span&gt;&lt;span class="sr"&gt;$/&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DISCORD_BOT_TOKEN is malformed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bot&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Envapt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;DISCORD_BOT_TOKEN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;converter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;validateDiscordToken&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="kr"&gt;declare&lt;/span&gt; &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;botToken&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// string; a malformed token throws here&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;t3-env centralizes: you declare every variable up front in one &lt;code&gt;createEnv&lt;/code&gt; call, validated once at startup. envapt puts the check on the field that uses the value. Centralizing is the right call when one app owns all its env. seedcord's config is spread across independently-built pieces (the &lt;code&gt;Bot&lt;/code&gt; owns the token, a webhook subscriber owns its URL), so each piece validates its own variable where it lives, and a malformed token throws the moment that field resolves instead of in a central config module three files away.&lt;/p&gt;

&lt;h2&gt;
  
  
  The same reads, off Node
&lt;/h2&gt;

&lt;p&gt;On Node, Bun, and Deno, envapt reads &lt;code&gt;process.env&lt;/code&gt; and the &lt;code&gt;.env&lt;/code&gt; cascade with no setup. On Cloudflare Workers and in the browser there is no filesystem, so you bind the source yourself, and once it's bound the typed reads, converters, and validators are identical.&lt;/p&gt;

&lt;p&gt;In a Worker, &lt;code&gt;env&lt;/code&gt; is readable at module scope and constant for a deployment, so bind it once in a config module and export the typed values. That way binding happens once per isolate, not on every request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// config.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;env&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cloudflare:workers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;WorkerEnvSource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;envapt/workerd&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;useSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;WorkerEnvSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ORIGIN_URL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API_TOKEN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ORIGIN_URL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Url&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;token&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API_TOKEN&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// index.ts&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;request&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;search&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;origin&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="nx"&gt;satisfies&lt;/span&gt; &lt;span class="nx"&gt;ExportedHandler&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the browser, bind whatever your bundler injects:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ManualEnvSource&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;envapt/browser&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Vite replaces import.meta.env at build time; or a webpack DefinePlugin object&lt;/span&gt;
&lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;useSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ManualEnvSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;meta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;apiBase&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Envapter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsing&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;API_BASE_URL&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Converters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Import from &lt;code&gt;envapt/workerd&lt;/code&gt; or &lt;code&gt;envapt/browser&lt;/code&gt;, not bare &lt;code&gt;envapt&lt;/code&gt;: those entries pull in no &lt;code&gt;node:&lt;/code&gt; modules and drop the file-only APIs from the types, so a stray file call is a compile error instead of a runtime surprise. The &lt;code&gt;.env&lt;/code&gt; cascade and the file APIs stay on Node, Bun, and Deno.&lt;/p&gt;

&lt;h2&gt;
  
  
  Loading the .env file
&lt;/h2&gt;

&lt;p&gt;For local development you still want a &lt;code&gt;.env&lt;/code&gt; file. On Node that's usually &lt;code&gt;dotenv&lt;/code&gt;. envapt parses &lt;code&gt;.env&lt;/code&gt; itself, so it loads the file without adding a dependency:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;envapt/config&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That import is a drop-in for &lt;code&gt;dotenv/config&lt;/code&gt;. It reads the cascade and mirrors the result into &lt;code&gt;process.env&lt;/code&gt;. The cascade is per-environment and the most-specific file wins:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="err"&gt;.env.production.local&lt;/span&gt;
&lt;span class="err"&gt;.env.production&lt;/span&gt;
&lt;span class="err"&gt;.env.local&lt;/span&gt;
&lt;span class="err"&gt;.env&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;${VAR}&lt;/code&gt; references expand while the file is parsed, so &lt;code&gt;DATABASE_URL=postgres://${DB_HOST}/${DB_NAME}&lt;/code&gt; resolves on its own. You don't strictly need that import, either. Drop it and the typed reads still work; they read the cascade directly. The import is only there for the libraries that read &lt;code&gt;process.env&lt;/code&gt; straight, before envapt does.&lt;/p&gt;

&lt;h2&gt;
  
  
  So, finally
&lt;/h2&gt;

&lt;p&gt;What envapt gives you is the combination: a fallback that narrows the type and tells missing from zero, converters for the shapes that aren't strings, and validation through the schema you already wrote rather than the one a helper chose for you. If that's the shape of your config problem, the docs and the v4-to-v5 migration are at &lt;a href="https://envapt.materwelon.dev" rel="noopener noreferrer"&gt;envapt.materwelon.dev&lt;/a&gt;, it's on &lt;a href="https://www.npmjs.com/package/envapt" rel="noopener noreferrer"&gt;npm&lt;/a&gt; and &lt;a href="https://jsr.io/@materwelon/envapt" rel="noopener noreferrer"&gt;JSR&lt;/a&gt;, and the source is on &lt;a href="https://github.com/materwelonDhruv/envapt" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;. Please feel free to ask questions, report bugs, or suggest features in the repo! I'm always open to feedback and contributions.&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>node</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
