Rediger

Del via


Quickstart: Create a code app from scratch (preview)

This article walks through how to set up a blank app from Vite and turn it into a Power Apps code app. It covers configuring a TypeScript app using the Power Platform SDK.

Note

Preview features aren’t meant for production use and may have restricted functionality. These features are available before an official release so that customers can get early access and provide feedback.

Prerequisites

Steps

  1. Open a new terminal and enter:

    npx degit github:microsoft/PowerAppsCodeApps/templates/vite my-app
    cd my-app 
    
  2. Authenticate the Power Platform CLI against your Power Platform tenant and select your environment:

    pac auth create
    pac env select --environment {environment id}
    

    Sign in using your Power Platform account when prompted. All Power Platform apps, flows, and agents publish to an environment. The PAC CLI's auth command prompts you to authenticate with your Microsoft Entra identity and ensure the code app you add connections to and publish to Power Platform go in the specified environment.

  3. Install the Power SDK and initialize your code app using:

    npm install
    pac code init --displayname "App From Scratch"
    
  4. Enter the following to test your code app locally:

    npm run dev 
    

Then, open the URL labelled Local Play.

Important

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

You should see the app open similar to:

See the test app playing locally in the browser

Build and deploy to Power Apps

In the terminal window, run these commands:

npm run build | pac code push
  • npm run build Runs the scripts configured in the package.json file with the key value of build. In this case, the script is "tsc -b && vite build".
  • pac code push Publishes a new version of a Code app.

If successful, this command should return a Power Apps URL to run the app.

Optionally, you can open Power Apps to see the app. You can play, share, or see details from there.

Congratulations! You successfully pushed your first code app!