Wendy LogoWendy

Hello World in TypeScript

Create your first WendyOS application using TypeScript

Creating Your First TypeScript Application

This guide will walk you through creating a simple "Hello, World!" application for WendyOS using TypeScript. This is a great way to prove that you can send your first app to your device and verify your development environment is set up correctly.

Prerequisites

  • Wendy CLI installed on your development machine
  • Node.js 22 or later installed
  • A WendyOS device plugged in over USB or connectable over Wi-Fi

Containerized Deployment: TypeScript applications run inside containers on your WendyOS device. This guide shows you how to package the Node.js runtime for deployment with the Wendy CLI.

Creating the Project

Initialize the Project

Start from the Wendy TypeScript template:

wendy init hello-world --target wendyos --language node --template simple-api --var APP_ID=hello-world --var PORT=5001 --assistant skip --git-init no
cd hello-world

The template creates package.json, tsconfig.json, src/index.ts, Dockerfile, and wendy.json. Continue below to understand the generated project.

Run on WendyOS

wendy run

Wendy will build the app, ask you to select a device if one is not already configured, deploy the app, and show the run output.

Code Breakdown

Generated Application

The template includes src/index.ts. A minimal hello-world entry point looks like:

mkdir src
// src/index.ts
console.log("Hello, World!");

Generated package.json

The generated package.json includes build and start scripts:

{
  "name": "hello-world",
  "version": "0.1.0",
  "type": "module",
  "scripts": {
    "build": "tsc",
    "start": "node dist/index.js",
    "dev": "tsx src/index.ts"
  },
  "devDependencies": {
    "@types/node": "^22",
    "typescript": "^5.7",
    "tsx": "^4"
  },
  "engines": {
    "node": ">=22"
  }
}

Generated tsconfig.json

The generated tsconfig.json specifies the output directory and module settings:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "outDir": "./dist",
    "rootDir": "./src",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,
    "declaration": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "dist"]
}

Generated Dockerfile

The generated project includes a Dockerfile:

# Build stage
FROM node:22-slim AS builder

WORKDIR /app
COPY package*.json ./
RUN npm install

COPY tsconfig.json ./
COPY src ./src
RUN npm run build

# Runtime stage
FROM node:22-slim

WORKDIR /app
COPY --from=builder /app/dist ./dist

CMD ["node", "dist/index.js"]

Run Again on WendyOS

Deploy your containerized application to your WendyOS device:

wendy run

Verifying Deployment on Your Device

After deploying your application to a WendyOS device, you can verify it was successfully deployed and ran by listing the applications on your device:

wendy device apps list
✔︎ Searching for WendyOS devices [5.3s]
✔︎ Listing applications: True Probe [USB, Ethernet, LAN]
╭───────────────┬─────────┬─────────┬──────────╮
 App Version State Failures
├───────────────┼─────────┼─────────┼──────────┤
 hello-world 0.0.1 Stopped 0
╰───────────────┴─────────┴─────────┴──────────╯

Expected State: The app shows as "Stopped" because a hello-world application exits immediately after printing its message. This is expected behavior. The key indicator of success is the "Failures" column showing 0, which confirms your application ran and exited successfully without any errors.

Next Steps

Now that you have a basic TypeScript application running:

  • Learn how to build a Simple Web Server with Express
  • Explore environment variables and configuration
  • Build more complex applications with networking and data processing
  • Integrate with WendyOS device features via HTTP APIs