Fix · Capacitor · Android

    Fix Capacitor "Could not find the web assets directory"

    Nathan Claiborne
    Capacitor wraps a folder of built web files into a native app. When that folder isn’t where webDir says, or has no index.html, npx cap sync stops before anything native happens. It was the most common reason Capacitor builds stopped on Corenna in October and November 2026. Here are the exact messages, the four usual causes, and the fix for each.

    The error

    When the folder doesn’t exist, Capacitor 8 prints:

    [error] Could not find the web assets directory: ./dist.
    Please create it and make sure it has an index.html file. You can change the path of this directory in capacitor.config.ts (webDir option). You may need to compile the web assets for your app (typically npm run build).

    When the folder exists but the build didn’t put an index.html in it:

    [error] The web assets directory (./dist) must contain an index.html file.
    It will be the entry point for the web portion of the Capacitor app.

    Both mean the same thing: webDir in your Capacitor config has to name the folder your web build writes, and that folder has to hold a finished, static index.html.

    Cause 1: the build never ran

    webDir is filled by your web build, not by Capacitor. On a fresh checkout or a CI machine the folder doesn’t exist until you run npm run build (or your package manager’s equivalent), so the order is always build, then npx cap sync. If your build script only type-checks (for example "build": "tsc"), it writes no index.html either: make it run your bundler.

    Cause 2: webDir names the wrong folder

    Each framework writes to its own folder by default. Set webDir to match:

    • Vite: dist
    • Create React App: build
    • Next.js with a static export: out (see cause 3)
    • Angular 17 and newer: dist/<project-name>/browser (see cause 4)
    // capacitor.config.ts
    import type { CapacitorConfig } from "@capacitor/cli";
    
    const config: CapacitorConfig = {
      appId: "com.example.app",
      appName: "My App",
      webDir: "dist",
    };
    
    export default config;

    If you changed the output folder yourself, for example with build.outDir in vite.config.ts, webDir has to name that folder instead.

    Cause 3: a Next.js app that renders on a server

    A plain next build prepares the app for a Node server and writes no index.html that Capacitor can use. Ask for a static export instead, and next build writes the whole site to out:

    // next.config.js
    module.exports = {
      output: "export",
      images: { unoptimized: true },
    };

    Anything that needs the server, such as API routes, server actions or getServerSideProps, doesn’t exist inside the app after this: point those calls at a server you host and keep the app itself static. images: { unoptimized: true } is there because the default image optimizer also needs a server.

    Cause 4: Angular 17 puts the files one folder deeper

    Since Angular 17 the application builder writes the browser files to dist/<project-name>/browser, so a webDir of dist or dist/<project-name> finds no index.html. Either set webDir to the full path, or flatten the output in angular.json (Angular 17.1 or newer):

    // angular.json: projects.<project-name>.architect.build.options
    "outputPath": {
      "base": "dist",
      "browser": ""
    }

    With that, ng build writes index.html straight into dist.

    How Corenna handles it

    Corenna runs your build script on GitHub Actions in your own repo, then checks the output before any native step. It expects index.html in your framework’s folder (out for Next.js, build for Create React App, dist for Vite, Astro and Angular). If it isn’t there, Corenna looks in dist, build, out, www, public/build, .output/public and dist/spa, and uses the first one that has it. When none does, the build stops at the “Verify web output” step with:

    The build finished but produced no index.html in dist/. Point your build at a static output folder (Vite: build.outDir) so Corenna can wrap it into the app.

    Angular 17’s dist/<project-name>/browser isn’t one of the folders Corenna looks in, so use the outputPath change above. If your capacitor.config.json names a folder the build didn’t write, Corenna points webDir at the folder it found and logs a warning. A capacitor.config.ts or .js it doesn’t edit: the build stops with “Capacitor webDir mismatch” and names the folder to use, because an app pointed at the wrong folder installs and opens to a blank screen.

    Apps made with Lovable on its newer TanStack Start setup don’t produce a static index.html at all; Corenna builds those differently, as this guide explains. Building your Android app is free. Downloading it needs a plan: $1 for your first month.

    Keep reading