1
Install StackMachine
Add the SDK to the backend that will create, deploy, and manage apps for your users.
Shell
$ npm install stackmachineDeploy Node.js, Python, PHP, WordPress, and more on infrastructure built for density, fast cold starts, and affordable scaling.
$ npm install stackmachineimport StackMachine from "stackmachine";
const client = new StackMachine(process.env.STACKMACHINE_API_KEY);
const deployment = await client.deployments.create({
appName: "my-express-app",
files: {
"package.json": JSON.stringify({
type: "module",
dependencies: { express: "^4.18.3" },
}),
"server.js": `import express from "express";
const app = express();
const port = process.env.PORT || 3000;
app.get("/", (_req, res) => {
res.send("<h1>Hello from Express on StackMachine!</h1>");
});
app.listen(port, () => {
console.log("Express app listening on " + port);
});
`,
},
});
const appVersion = await deployment.wait({
onProgress: ({ message, datetime }) => {
if (message) console.log(datetime, message);
},
});
const app = await client.apps.retrieve(appVersion.app.id);
console.log("App deployed!", app.url);