feat: Add Node 24 support to Vercel adapter (#14982)
authorElliott Johnson <elliott.johnson@vercel.com>
Tue, 25 Nov 2025 19:58:40 +0000 (12:58 -0700)
committerGitHub <noreply@github.com>
Tue, 25 Nov 2025 19:58:40 +0000 (12:58 -0700)
* feat: Add Node 24 support to Vercel adapter

* changeset

* tweak error message

.changeset/giant-sites-relate.md [new file with mode: 0644]
packages/adapter-vercel/index.d.ts
packages/adapter-vercel/index.js
packages/adapter-vercel/utils.js

diff --git a/.changeset/giant-sites-relate.md b/.changeset/giant-sites-relate.md
new file mode 100644 (file)
index 0000000..077917b
--- /dev/null
@@ -0,0 +1,5 @@
+---
+'@sveltejs/adapter-vercel': minor
+---
+
+feat: Node 24 support
index 8d37ce4cc409d3a7c069637d3560459cd079c48c..c4ea25f7c4a21007958c549e29aacf13497fbe7e 100644 (file)
@@ -6,7 +6,7 @@ export default function plugin(config?: Config): Adapter;
 
 export interface ServerlessConfig {
        /**
-        * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
+        * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs22.x'`, `'nodejs24.x'` etc).
         * @default Same as the build environment
         */
        runtime?: Exclude<RuntimeConfigKey, 'edge'>;
@@ -78,7 +78,7 @@ type ImagesConfig = {
 /** @deprecated */
 export interface EdgeConfig {
        /**
-        * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs18.x'`, `'nodejs20.x'` etc).
+        * Whether to use [Edge Functions](https://vercel.com/docs/concepts/functions/edge-functions) (`'edge'`) or [Serverless Functions](https://vercel.com/docs/concepts/functions/serverless-functions) (`'nodejs22.x'`, `'nodejs24.x'` etc).
         */
        runtime?: 'edge';
        /**
index b001407c6560418f3137a589e8696d29603acab3..f54765d7536bc51b76728e2a375f79ff09f814fc 100644 (file)
@@ -285,7 +285,7 @@ const plugin = function (defaults = {}) {
 
                                        if (runtime === 'edge') {
                                                throw new Error(
-                                                       `${directory}: Routes using \`isr\` must use a Node.js or Bun runtime (for example 'nodejs22.x' or 'experimental_bun1.x')`
+                                                       `${directory}: Routes using \`isr\` must use a Node.js or Bun runtime (for example 'nodejs24.x' or 'experimental_bun1.x')`
                                                );
                                        }
 
index 983b30bbb5be0a2fa62fbafcc5a131a7a88fe0b6..d7723e1a2af93a8664d6e97a7ea1777ac4e309b6 100644 (file)
@@ -120,6 +120,8 @@ export function resolve_runtime(default_key, override_key) {
        return key;
 }
 
+const valid_node_versions = [20, 22, 24];
+
 /** @returns {RuntimeKey} */
 function get_default_runtime() {
        // TODO may someday need to auto-detect Bun, but this will be complicated because you may want to run your build
@@ -127,16 +129,22 @@ function get_default_runtime() {
        // to tell us what the bun configuration is.
        const major = Number(process.version.slice(1).split('.')[0]);
 
-       if (major !== 20 && major !== 22) {
+       if (!valid_node_versions.includes(major)) {
                throw new Error(
-                       `Unsupported Node.js version: ${process.version}. Please use Node 20 or 22 to build your project, or explicitly specify a runtime in your adapter configuration.`
+                       `Unsupported Node.js version: ${process.version}. Please use Node ${valid_node_versions.slice(0, -1).join(', ')} or ${valid_node_versions.at(-1)} to build your project, or explicitly specify a runtime in your adapter configuration.`
                );
        }
 
-       return `nodejs${major}.x`;
+       return `nodejs${/** @type {20 | 22 | 24} */ (major)}.x`;
 }
 
-const valid_runtimes = /** @type {const} */ (['nodejs20.x', 'nodejs22.x', 'bun1.x', 'edge']);
+const valid_runtimes = /** @type {const} */ ([
+       'nodejs20.x',
+       'nodejs22.x',
+       'nodejs24.x',
+       'bun1.x',
+       'edge'
+]);
 
 /**
  * @param {string} key