Build your first design

Install the Stitch SDK and generate your first UI screen in under five minutes.

The Stitch SDK (@google/stitch-sdk) lets you generate, edit, and manage UI designs directly from TypeScript. No MCP config files, no CLI setup-just npm install and go.

By the end of this tutorial, you’ll have a working script that creates a project, generates a screen, and retrieves the HTML and image URLs.

google-labs-code / stitch-sdk Star TypeScript SDK for the Stitch design generation API TypeScript @google/stitch-sdk

What you’ll need

Install the SDK

npm

npm install @google/stitch-sdk

Bun

bun add @google/stitch-sdk

Set your API key

Export your key as an environment variable. The SDK picks it up automatically.

export STITCH_API_KEY="your-api-key"

Write the script

Create a file called my-first-design.ts:

import { stitch } from "@google/stitch-sdk";

// 1. Create a project
const project = await stitch.createProject("My First App");
console.log(`Project created: ${project.id}`);

// 2. Generate a screen
const screen = await project.generate("A simple login page with email and password fields");
console.log(`Screen generated: ${screen.id}`);

// 3. Get your outputs
const htmlUrl = await screen.getHtml();
const imageUrl = await screen.getImage();

console.log(`HTML:  ${htmlUrl}`);
console.log(`Image: ${imageUrl}`);

Run it

tsx

npx tsx my-first-design.ts

Bun

bun my-first-design.ts

You’ll see output that looks like this:

Project created: 4044680601076201931
Screen generated: 98b50e2ddc9943efb387052637738f61
HTML:  https://...
Image: https://...

Open the HTML URL in your browser. You’ll see a fully styled login page with Tailwind CSS baked in.

What just happened?

You used three core SDK concepts:

  1. stitch - The default singleton. It connects to the Stitch MCP server using your API key.
  2. project.generate(prompt) - Sends a prompt to Stitch and returns a Screen object.
  3. screen.getHtml() / screen.getImage() - Retrieves download URLs for the generated design.

The SDK gives you a fluent, object-oriented API: stitch → Project → Screen. Each object knows how to navigate to the next.

Next steps

Now that you have a working design, try these:

Original: https://stitch.withgoogle.com/docs/sdk/tutorial/

Translated from the official Google Stitch documentation. Original content © Google LLC. This is an independent, unofficial translation.