Build a Node.js app¶
Snowflake App Runtime runs Node.js apps on Node.js 22. Start from the Next.js template, or bring the framework and stack you already use, such as Express, Fastify, or your own Next.js app.
Start from the Next.js template¶
The template comes configured for App Runtime, with Snowflake data access through the Node.js SDK. Create an app from it in any of these ways:
- Snowsight Workspaces (Public Preview): select + Add new » Next.js App.
- Cortex Code: describe the app with the
snowflake-appsskill.
For each step through deploy, see Get started with Snowflake App Runtime.
Bring your own framework¶
Any Node.js app runs on App Runtime if it can be installed and built with commands and serves HTTP on the address App Runtime gives it. You need the Snowflake CLI with a connection, and Node.js 22 or later on your machine.
-
From the project directory, generate an
app.ymlmanifest: -
Add the commands that install, build, and run the app. The build runs only the commands you declare. See the examples for Next.js and other frameworks.
-
Have the server listen on the
PORTandHOSTNAMEthat App Runtime sets. See Listen address. -
Deploy the app, then open it:
Next.js¶
In next.config.*, set output: "standalone". App Runtime runs the standalone
server that Next.js builds, and that server already reads PORT and
HOSTNAME. Add these commands to app.yml:
The standalone output doesn’t include static assets, so the cp commands copy
them in. Without them, static files return 404 after deploy. Omit the public
line if the project has no public/ directory. The rm command keeps the root
node_modules out of the deployed app, because the standalone output has its
own.
To preview the app in Snowsight Workspaces,
keep the dev script in package.json that runs next dev.
Express and other frameworks¶
For Express, Fastify, or another Node.js server, install dependencies and run
the entry point. Add a build command only if the app has a build step.
This Express app deploys as is. Create three files in an empty directory:
package.json:
server.js listens on the PORT and HOSTNAME that App Runtime sets:
app.yml:
npm ci needs a package-lock.json, so run npm install once before you
deploy. Then deploy and open the app:
Replace database, schema, and query_warehouse with your own, or run
snow app setup to fill them in from your account’s defaults.
Query Snowflake¶
Install the Node.js SDK and call it from server code: server components, route handlers, and server actions.
For owner’s and caller’s rights queries, see Query Snowflake from a Snowflake App Runtime app.
Run locally¶
Run npm run dev. On your machine, the SDK uses the default connection in your
Snowflake CLI configuration, and caller’s rights queries run as that
connection’s user.
Next steps¶
- Deploy more than one way from one project: Deploy targets for Snowflake App Runtime.
- Run an app on serverless compute: Serverless compute for Snowflake App Runtime.
- Share the app with other roles: Share a Snowflake App Runtime app.