Code Sites: Power Pages for People Who Want to Write the Front End
Bring your own React, Angular, Vue or Astro, hand the rest to the platform, and find out what you've just signed away
The series was finished. Then Microsoft moved the goalposts.
Post 30 ended with the words “that’s the series”, and I meant it. Then Power Pages grew a second way of building sites, and the line early in this series about pro-code “escape hatches” started to look like it was written by someone who had never seen the fire exit. So: two more posts.
What a code site is
A code site, or single-page application (SPA) site in Microsoft’s documentation, is a Power Pages site where the front end is something you compiled yourself: React, Angular, Vue, Astro, anything that produces HTML, JavaScript and CSS. You build it locally, upload it with the Power Platform CLI, and Power Pages serves it.
Power Pages still does everything behind the front end: hosting, authentication providers, web roles, table permissions, the Web API in front of Dataverse, the web application firewall, and now server logic. It no longer renders anything. Public preview May 2025, general availability end of January 2026, a few weeks after the first post in this series.
Step by step
You need PAC CLI 1.44 or newer, a site on runtime 9.7.4 or later, and an environment that allows JavaScript file uploads. Some environments block .js attachments by default, and the upload fails with an unhelpful message about attachment types. Remove js from the blocked extensions list in the Power Platform admin center, under the environment’s privacy and security settings.
Then, from a normal front-end project:
npm create vite@latest my-portal -- --template react-ts
cd my-portal
npm install
npm run build
Add a powerpages.config.json in the project root:
{
"$schema": "https://www.schemastore.org/powerpages.config.json",
"siteName": "Contoso Customer Portal",
"compiledPath": "dist",
"defaultLandingPage": "index.html",
"bundleFilePatterns": ["index-*.js", "index-*.css"]
}
Authenticate and upload:
pac auth create --environment https://yourorg.crm4.dynamics.com
pac pages upload-code-site --rootPath .
The site turns up under Inactive sites in the Power Pages home; activate it and pick a subdomain. Every later upload-code-site run updates the live site, so the deploy pipeline is npm run build and one CLI command.
bundleFilePatterns matters more than it looks. Every build produces new content-hashed file names, and without those patterns old bundles pile up in the site’s web files forever. List a wildcard per output file, or use the post-build script from Microsoft’s documentation.
To pull a site’s code back down, because someone deployed from a laptop and went on holiday:
pac pages download-code-site --path ./downloaded --webSiteId <site-guid> --overwrite
What comes back is the compiled output, not the project. includeSource in powerpages.config.json defaults to false, so unless the upload set it to true, the source only exists on that laptop.
Authentication, data and the bits you don’t rewrite
The security model is identical to a traditional site, and that is the point. Identity providers are configured in the same place, every new site gets a default Entra ID provider, and web roles and table permissions apply unchanged. The current user is on the global object:
const user = (window as any).Microsoft?.Dynamic365?.Portal?.User;
const signedIn = Boolean(user?.userName);
Sign-in is a POST to /Account/Login/ExternalLogin with the anti-forgery token from /_layout/tokenhtml, sign-out a redirect to /Account/Login/LogOff. Data access is the Web API at /_api/<entitysetname>, with the same Webapi/<table>/enabled and Webapi/<table>/fields site settings and the same __RequestVerificationToken header on every call, reads included. An existing fetch wrapper works unchanged.
Page-level security changes shape. There are no page permissions because there are no pages. You check roles on the client and render conditionally; table permissions do the enforcement. Client-side checks are a user experience feature, not a security boundary. That was always true; a SPA makes it easier to forget.
For local development you run Vite with a proxy to the live site’s /_api, enable bearer authentication with three site settings, and sign in from localhost through an Entra app registration. The conditions: runtime 9.7.6.6 or later, site visibility set to Public, and Microsoft says development environments only. The documentation insists on Entra v1 endpoints and ADAL.js rather than MSAL, odd in 2026, but it works.
Server logic
Server logic is server-side JavaScript inside the Power Pages runtime, protected by web roles and table permissions, reachable at /_api/serverlogics/<name>. Preview October 2025, general availability April 2026. ECMAScript 2023 without browser APIs, authored in VS Code for the Web, with an HttpClient for external services and server-side Dataverse operations.
For a code site this is the missing piece. Anything that needs a secret, calls an external API, or validates data the client must not bypass now has a home that isn’t a separately paid and secured Azure Function. Custom APIs in Dataverse are still the answer for heavy logic; server logic is for the lighter end.
When to pick this over a traditional site
Pick a code site when:
- Your team already writes React, Angular or Vue and finds Liquid a step backwards
- The user experience is the product: rich interaction, client-side state, instant feedback
- You want a component library, TypeScript, unit tests and a normal CI pipeline
- Nobody has asked for the design studio
Stay traditional when:
- Content editors need to change pages without a developer and a build step
- You need Liquid’s server-side rendering to get Dataverse data into HTML without an API round trip
- Search engines matter; client-side rendering and SEO are not friends
- You rely on out-of-the-box lists, basic forms or multistep forms
The short test: if the team’s instinct is to open VS Code, pick a code site. If it’s the design studio, don’t.
What you give up
The list is longer than the marketing suggests:
- Liquid and web templates. Gone. Server-rendered logic becomes API calls.
- The Pages and Styling workspaces. Not supported. Styling is whatever your framework does.
- Out-of-the-box lists and forms. You build them against the Web API, which gets expensive once you add validation, lookups and file uploads.
- Multi-language. Single language as far as the platform is concerned; client-side resources are your problem.
- Page permissions. Replaced by conditional rendering and table permissions.
- Progressive web app settings. The Set up workspace switch doesn’t apply. Add a manifest and service worker yourself.
- Git integration and test tooling. Git integration doesn’t support SPA sites and there is no platform test tooling. Source and tests live in your own repository and pipeline, as they should.
Licensing is unchanged: the same authenticated and anonymous per-user capacity, no extra line item for writing your own front end.
Where the tooling went while I wasn’t looking
Microsoft now ships a Power Pages plugin for GitHub Copilot CLI and Claude Code that scaffolds and deploys a code site, creates the Dataverse tables, generates the Web API client and table permissions, sets up authentication and runs a security review, each as a slash command you approve step by step. How much of that to let an agent do unsupervised is for the next post.
Useful links
- Create and deploy a single-page application in Power Pages
- pac pages command reference
- Server logic overview
- Power Pages Web API overview
- Power Pages plugin for GitHub Copilot CLI and Claude Code
The short version
A code site is Power Pages with the rendering layer removed and your framework in its place. You keep the security model, the Web API, hosting and licensing. You lose Liquid, the design studio, the built-in components and multi-language. For a developer-led team building something interactive, it’s the Power Pages I’d have asked for in 2024. For a content-led team, a trap with a nice build pipeline.
Next up: Copilot and the AI features, or what happens when the platform starts writing the site for you.