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
- Docker installed (see Docker Installation)
- A WendyOS device plugged in over USB or connectable over Wi-Fi
Containerized Deployment: TypeScript applications run inside Docker containers on your WendyOS device. This guide shows you how to set up containers for the Node.js runtime. See the Docker Installation guide for setup instructions.
Creating the Project
Initialize the Project
Initialize a new Node.js project with TypeScript:
npm init -y
npm install --save-dev typescript @types/node tsx
npx tsc --initCreate the Application
Create a src/index.ts file:
mkdir src// src/index.ts
console.log("Hello, World!");Update package.json
Update your package.json to add 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"
}
}Update tsconfig.json
Update your tsconfig.json to specify 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"]
}Create a Dockerfile
Create a Dockerfile in the project root:
# 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"]Deploy to WendyOS Device
Deploy your containerized application to your WendyOS device:
wendy runVerifying 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