# UPDATED: Create IC App - Modern, unopinionated templates for all frameworks

**URL:** <https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589>\
**Category:** Developers\
**Created:** [April 24, 2021, 1:12pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589 "2021-04-24T13:12:42Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![ansleydsouza](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ansleydsouza/32/1678_2.png) [@ansleydsouza](https://forum.dfinity.org/u/ansleydsouza)\
**Post date:** [May 23, 2021, 8:21am UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/23 "2021-05-23T08:21:23Z")

</div>

@Tbd

Thanks a lot for your help. Changing the @dfinity/agent to 0.8.7 did the trick along with cleaning the npx cache.

I was previously on 0.8.6.

Thanks!

---

<div class="post-metadata">

**Author:** ![amaralc](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/amaralc/32/2081_2.png) [@amaralc](https://forum.dfinity.org/u/amaralc)\
**Post date:** [June 5, 2021, 5:02am UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/24 "2021-06-05T05:02:56Z")

</div>

Great project @Tbd! I managed to run a React+TS template on my local network (after upgrading node to v16+ and dfx to 0.7+) and it was seamless! Thank you very much!

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [June 5, 2021, 11:23pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/25 "2021-06-05T23:23:06Z")

</div>

Glad to hear that! Keeps me motivated to work on it.

---

<div class="post-metadata">

**Author:** ![ajerni](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/ajerni/32/2104_2.png) [@ajerni](https://forum.dfinity.org/u/ajerni)\
**Post date:** [June 6, 2021, 1:58pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/26 "2021-06-06T13:58:26Z")

</div>

Amazing work! I tried the comand line tool and selected svelte. Works just out of the box.

Now I just neet do learn svelte as well 🙂

Will you include support for IC Mainnet deployment as well as soon as it opens to the public?

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [June 6, 2021, 2:37pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/27 "2021-06-06T14:37:24Z")

</div>

Oh yeah, ofc! Tbh it should just work out of the box since it can already run fine on your local replica, but I could definitely add instructions to the readme for convenience.

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [June 13, 2021, 2:42pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/28 "2021-06-13T14:42:05Z")

</div>

Upgraded dfx to 0.7.0 and added instructions on deploying the asset canister through fleek (super easy!)

Got my own projects site up and running with this 🙂  
[https://3ve4r-liaaa-aaaad-qaena-cai.raw.ic0.app/](https://3ve4r-liaaa-aaaad-qaena-cai.raw.ic0.app/)

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 6, 2021, 7:27pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/29 "2021-07-06T19:27:20Z")

</div>

I created a small playground with your vite template. I followed your instructions on the github repo but I’m getting an error. Take a look below:

Deploy started at 2021-07-06T19:39:53.723Z

2021-07-06T19:39:56.386Z: Deploy started  
2021-07-06T19:40:00.975Z: Docker image: ‘fleek/create-react-app’  
2021-07-06T19:40:00.975Z: Build command: ‘npm install && npm run build’  
2021-07-06T19:40:00.975Z: Triggering build execution…  
2021-07-06T19:41:24.236Z: added 205 packages, and audited 205 packages in 7s  
2021-07-06T19:41:24.236Z: 21 packages are looking for funding  
2021-07-06T19:41:24.236Z: run `npm fund` for details  
2021-07-06T19:41:24.252Z: 4 moderate severity vulnerabilities  
2021-07-06T19:41:24.252Z: To address all issues, run:  
2021-07-06T19:41:24.252Z: npm audit fix  
2021-07-06T19:41:24.252Z: Run `npm audit` for details.  
2021-07-06T19:41:24.253Z: npm notice  
2021-07-06T19:41:24.253Z: npm notice New minor version of npm available! 7.0.8 → 7.19.1  
2021-07-06T19:41:24.253Z: npm notice Changelog: [https://github.com/npm/cli/releases/tag/v7.19.1](https://github.com/npm/cli/releases/tag/v7.19.1)  
2021-07-06T19:41:24.253Z: npm notice Run `npm install -g npm@7.19.1` to update!  
2021-07-06T19:41:24.253Z: npm notice  
2021-07-06T19:41:24.523Z: \> ic-rewind@0.0.0 build  
2021-07-06T19:41:24.523Z: \> vite build  
2021-07-06T19:41:24.836Z: vite v2.3.3 building for production…  
2021-07-06T19:41:24.901Z: transforming…  
2021-07-06T19:41:29.184Z: ✓ 74 modules transformed.  
2021-07-06T19:41:29.184Z: Could not load /workspace/.dfx/local/canisters/playground/playground.js (imported by src/agent.js): ENOENT: no such file or directory, open ‘/workspace/.dfx/local/canisters/playground/playground.js’  
2021-07-06T19:41:29.184Z: error during build:  
2021-07-06T19:41:29.184Z: Error: Could not load /workspace/.dfx/local/canisters/playground/playground.js (imported by src/agent.js): ENOENT: no such file or directory, open ‘/workspace/.dfx/local/canisters/playground/playground.js’  
2021-07-06T19:41:29.202Z: npm ERR! code 1  
2021-07-06T19:41:29.202Z: npm ERR! path /workspace  
2021-07-06T19:41:29.204Z: npm ERR! command failed  
2021-07-06T19:41:29.205Z: npm ERR! command sh -c vite build  
2021-07-06T19:41:29.224Z: npm ERR! A complete log of this run can be found in:  
2021-07-06T19:41:29.224Z: npm ERR! /root/.npm/\_logs/2021-07-06T19\_41\_29\_205Z-debug.log  
2021-07-06T19:41:54.789Z: Error occured during the build.

Any idea what is going on?

Thanks in advance!!!

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [July 6, 2021, 8:19pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/30 "2021-07-06T20:19:13Z")

</div>

Hey @ferMartz I haven’t actually tried deploying a frontend with canister calls yet 🤔 (only static one)  
it seems `.dfx` directory js isnt being included in the bundle maybe? What does the `dist` directory look like for you?

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 6, 2021, 8:28pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/31 "2021-07-06T20:28:11Z")

</div>

@Tbd you are right, no .dfx directory and the dist has only assets although it has an agent.xxxx.js. Do you know if there is a setting on fleek for deploying the canister?

I just found this tutorial from one of your peers I guess.  
[https://kyle-peacock.com/blog/dfinity/your-first-canister](https://kyle-peacock.com/blog/dfinity/your-first-canister)

BTW: I posted a question on Fleek’s slack channel about deploying a canister. Let’s see if they respond.

Any idea if there is another option for deploying canisters?

Thanks again!!

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [July 6, 2021, 10:12pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/32 "2021-07-06T22:12:27Z")

</div>

Strange. I tried locally with a frontend + canister call. there’s no dependencies to `.dfx` so bundling is working as it should.

Something in the fleek settings?

Here’s what I put in mine:

 ![image](https://us1.discourse-cdn.com/flex023/uploads/dfn/original/2X/0/0a84cd4285342a51b4e720002361ee0543cd5a7d.png)

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 7, 2021, 12:55am UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/33 "2021-07-07T00:55:30Z")

</div>

@Tbd those are the exact same settings I have.

I’ll keep trying and see if I can figure it out

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [July 7, 2021, 1:05am UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/34 "2021-07-07T01:05:23Z")

</div>

Can you try committing the `.dfx` folder to see if it works?  
Just occurred to me that fleek/create-react-app isn’t doing anything with dfx. will have to get that set up later. See if that works as a temporary solution

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 7, 2021, 12:58pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/35 "2021-07-07T12:58:53Z")

</div>

Your idea of committing .dfx works 🙌

Take a look here 👉 [https://wlyw6-viaaa-aaaad-qajia-cai.ic.fleek.co/](https://wlyw6-viaaa-aaaad-qajia-cai.ic.fleek.co)

Now the problem is that the queries and calls in production environment are directed to localhost:8000.  
I think there must be a tweak in vite.config.js or somewhere in the project. I’m looking into it.  
See shot below:  
[https://snipboard.io/cPqDWG.jpg](https://snipboard.io/cPqDWG.jpg)

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 7, 2021, 1:41pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/36 "2021-07-07T13:41:28Z")

</div>

Do you know the best practice to get the window.location.origin in the vite config file for production?

I tried few tweaks but none worked 😅

I read Vite’s docs about environment variables but I’m still confused.

I’m guessing I need to define DFX\_NETWORK in the production environment variable but is not working.

This is the line that is grabbing the root url in the vite config.

const networkName = process.env[“DFX\_NETWORK”] || “local”;

Thanks for help as always!!!

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [July 7, 2021, 1:48pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/37 "2021-07-07T13:48:06Z")

</div>

I found an example here, look in `src/agent.js` in your project

> <https://github.com/dfinity/cancan/blob/main/src/utils/canister/actor.ts>

Sorry I’m working night and day on my own project at the moment, otherwise I would have tried this already. Can you try taking the relevant bits from there and then continue via DMs if you run into trouble. Then we can post the final solution here.

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 7, 2021, 1:50pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/38 "2021-07-07T13:50:04Z")

</div>

Totally understand, I appreciate the help. I’ll try it and post the solution here.

Thanks again!!!

---

<div class="post-metadata">

**Author:** ![ferMartz](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/fermartz/32/1421_2.png) [@ferMartz](https://forum.dfinity.org/u/ferMartz)\
**Post date:** [July 7, 2021, 4:35pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/39 "2021-07-07T16:35:42Z")

</div>

Just to report that I was able to pass the previous error by adding the following code:

```auto
// Get environment from Vite env object
const ENV = import.meta.env.MODE;

// If is prod get the window location at port 8000 otherwise is local
const agentOptions = {
  host:
    ENV === "production"
      ? `${window.location.protocol}${window.location.host}:8000`
      : "http://localhost:8000",
};

const agent = new HttpAgent(agentOptions);

```

Now the problem is that the query/call never returns, it timeouts. I’m debugging the issue. Let me know if you have any idea.

You can take a look in the link I posted before.

---

<div class="post-metadata">

**Author:** ![Tbd](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/tbd/32/486_2.png) [@Tbd](https://forum.dfinity.org/u/Tbd)\
**Post date:** [July 8, 2021, 5:11pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/40 "2021-07-08T17:11:42Z")

</div>

Have you deployed the canisters to main net?

Also, remove the port 8000. This is what the request url says:  
[https://wlyw6-viaaa-aaaad-qajia-cai.raw.ic0.app:8000/api/v2/canister/rkp4c-7iaaa-aaaaa-aaaca-cai/call](https://wlyw6-viaaa-aaaad-qajia-cai.raw.ic0.app:8000/api/v2/canister/rkp4c-7iaaa-aaaaa-aaaca-cai/call)

---

<div class="post-metadata">

**Author:** ![anon74414410](https://avatars.discourse-cdn.com/v4/letter/a/85f322/32.png) [@anon74414410](https://forum.dfinity.org/u/anon74414410)\
**Post date:** [July 16, 2021, 5:36pm UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/41 "2021-07-16T17:36:57Z")

</div>

I’ll see if I can solve for Vite and open up a PR to the create-ic-app repo for `dfx` `0.7.7` and the latest `@dfinity/agent` versions. Probably sometime next week

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [July 20, 2021, 2:00am UTC](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589/42 "2021-07-20T02:00:02Z")

</div>

Any luck upgrading to dfx 0.7.7 for anyone? Vite is suddenly complaining that it can’t load files from dfx\_generated.

import { idlFactory as mycanister\_idl, canisterId as mycanister\_id } from ‘dfx-generated/mycanister’;

I noticed that new projects generated with dfx 0.7.7 end up with a /src/declarations folder. Not sure why I’m not getting that except that perhaps since vite never completes because of the error that the folder isn’t created? Do I need to swap out the webpack.configs with the new version? Vite should take care of that right?

Looks like I’ve gotten the error down to ‘default’ is not exported by .dfx/local/canisters/mycanister/mycanister.did.js, imported by .dfx/local/canisters/mycanister/mycanister.js

[Previous page](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589.md?page=1)

[Next page](https://forum.dfinity.org/t/updated-create-ic-app-modern-unopinionated-templates-for-all-frameworks/2589.md?page=3)
