Editéieren

Deelen iwwer


Quickstart: Create a code app from scratch by using the new npm CLI (preview)

Starting with Power Apps SDK version 1.0.4, the SDK includes an npm-based CLI for code apps. This new CLI reduces prerequisites for building code apps and replaces the Power Platform CLI's pac code commands, which are deprecated in a future release.

This article shows you how to install the Power Apps SDK, set up a blank app from Vite, and convert it into a Power Apps code app by using the new npm-based CLI commands.

Prerequisites

  • Power Platform environment with code apps enabled
  • Node.js (LTS version)
  • Git

Commands

The code apps npm CLI has three commands:

Command Description
init Initialize your code app.
run Starts a local development server.
push Publishes a new version of the code app to your environment.

Learn how to use these commands by following the steps in this article.

Step 1: Initialize the project

Open a terminal and run the following command:

npx degit github:microsoft/PowerAppsCodeApps/templates/vite my-app
cd my-app

Learn more about the degit command.

Step 2: Install dependencies and initialize the code app

Install the project dependencies and the Power Apps SDK:

npm install
npm install @microsoft/power-apps

Initialize your code app. You can either provide options directly or use interactive prompts:

Option A: Interactive mode (the CLI prompts you for required information):

npx power-apps init

Option B: Pass options directly:

npx power-apps init --displayName "App From Scratch" --environmentId <Your environment ID>

When you run the init command, the CLI authenticates you automatically. Sign in by using your Power Platform account when prompted.

Step 3: Test locally

Run the code app locally for development:

npx power-apps run

This starts a local development server. Open the URL labeled Local Play.

Important

Open the URL in the same browser profile as your Power Platform tenant.

Note

Local Network Access Restrictions

Since December 2025, Chrome and Microsoft Edge browsers block requests from public origins to local endpoints by default.

You should see the app open similar to:

See the test app playing locally in the browser

Build and deploy to Power Apps

Build your app and push it to your Power Apps environment:

npm run build
npx power-apps push

Command details:

  • npm run build - Runs scripts from package.json. Executes tsc -b && vite build.
  • npx power-apps push - Publishes a new version of the code app to your environment.

When the command finishes successfully, it returns a Power Apps URL to run the app.

Optionally, go to Power Apps to view, play, share, or review app details.