Deploy from files
Pass a files map to deployments.create. The SDK uploads your bundle; then call wait() on the returned deployment to stream build logs until the app is live.
Start a deployment
Pass appName / app_name, owner, and a files object whose keys are paths in the bundle. The call returns right away with a buildId and QUEUED status — the build has not finished yet.
Optional: envVars / env_vars, region, and upload progress (onUploadProgress / on_upload_progress).
deploy-from-files.js
1
// Request: appName, owner, files (required); optional envVars, region
2
const deployment = await client.deployments.create(
3
{
4
appName: "hello-stackmachine",
5
owner: "stackmachine",
6
files: {
7
"index.html": "<html><body><h1>Hello StackMachine</h1></body></html>",
8
},
9
envVars: [{ name: "NODE_ENV", value: "production", sensitive: false }], // sensitive: hide value in the dashboard
10
region: "iad", // region slug where the app is deployed
11
},
12
{
13
onUploadProgress: ({ percent }) => {
14
console.log("Upload progress %:", percent * 100);
15
},
16
},
17
);
18
// Should return: {// { ... }
23
console.log(deployment.buildId, deployment.status);
Wait for the build
Call wait() on the deployment object from the previous step. Use onProgress / on_progress to print build logs as they arrive. When the promise resolves, you get an app version with the live url and adminUrl / admin_url.
deploy-from-files.js
1
const appVersion = await deployment.wait({
2
onProgress: ({ datetime, stream, kind, message }) => {
3
// Should log: {
4
// "kind": "LOG",
5
// "message": "Building...",
6
// "datetime": "2024-01-15T12:00:00.000Z",
7
// "stream": "STDOUT"
8
// }
9
console.log(datetime, stream, kind, message);
10
},
11
});
12
// Should return: {// { ... }
21
console.log(appVersion.id, appVersion.app.url, appVersion.app.adminUrl);
Source: stackmachine/sdks examples.