How to link React built frontend?

I already have a React built frontend that I want to use for the ic, but I have problems linking it correctly.

My project contains a build/ directory with an index.html.
That html file links to everything needed (the build directory includes several sub directories and files alongside the index.html for assets and additional lazy loadable javascript, etc).

This is my dfx.json:

  "canisters": {
    "user": {
      "main": "backend/user/",
      "type": "motoko"
    "syra_frontend": {
      "dependencies": [
      "frontend": {
        "entrypoint": "build/index.html",
        "output": "/"
      "source": [
      "type": "assets"
  "defaults": {
    "build": {
      "output": "canisters/"
  "networks": {
    "local": {
      "bind": "localhost:8000",
      "type": "ephemeral"
    "tungsten": {
      "providers": [
      "type": "persistent"
  "dfx": "0.6.6",
  "version": 1

Using dfx it builds find on local and tungsten network and installation also runs without an error.
But opening the canister in the browser throws an error:

An error happened:
Error: Query failed:
  Status: rejected
  Message: not found

    at r.retrieve (
    at async _loadJs (
    at async _main (

I am not quite sure what is wrong with the config. Would be great if somebody can help out here :slight_smile:


The canister is bootstrapped with an html page you don’t see, which already contains an element with id=“app”. So target this from the react javascript in the render call as usual and it’ll populate that element, no need to use your own html page.

Point the entry point in dfx.json at this react index.jsx file.

There’s a great example react project here:

Or the tutorials include some too:


Thx I’ll check that out. Though the docs state that you can use your own html file as entry point here, which I would like to do.

1 Like

Also the thing is, that I have several web assembly modules and web worker javascript, etc. lying in the build/ directory. So I’d like to have a way to just include the HTML page and that pulls everything else.


I’m running into the same thing.

Currently, the bootstrap server only retrieves one entrypoint file, but I have a large webpack bundle with many chunks. I tried limiting it to a single chunk of 13mb, but that takes about 20s to download :confused:

Another question: I’m using React router, and I’m not sure how to handle routing (eg. vercel has custom routes). One solution would be to run my own nginx in front, I guess.

pinging @hansl @andrew_DFN


@wang Have you tried using a HashRouter for routing based on window.location.hash . I think it should work, but haven’t tried it yet.

1 Like