# Using modules in Coded Componen

**URL:** <https://community.appfarm.io/t/using-modules-in-coded-componen/1470>\
**Category:** Ask the community\
**Tags:** coded-component\
**Created:** [October 25, 2024, 8:09am UTC](https://community.appfarm.io/t/using-modules-in-coded-componen/1470 "2024-10-25T08:09:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lars.bergh.hvidsten](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/lars.bergh.hvidsten/32/2486_2.png) [@lars.bergh.hvidsten](https://community.appfarm.io/u/lars.bergh.hvidsten)\
**Post date:** [October 25, 2024, 8:09am UTC](https://community.appfarm.io/t/using-modules-in-coded-componen/1470/1 "2024-10-25T08:09:15Z")

</div>

Hi!

What is the best approach to use libraries that require es modules, import maps or just have an npm install and no CDN? For example [Three.js](https://threejs.org/docs/#manual/en/introduction/Installation) or [@thatopen/components](https://docs.thatopen.com/components/getting-started)

---

<div class="post-metadata">

**Author:** ![Simona](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/simona/32/201_2.png) [@Simona](https://community.appfarm.io/u/Simona)\
**Post date:** [November 4, 2024, 9:26am UTC](https://community.appfarm.io/t/using-modules-in-coded-componen/1470/2 "2024-11-04T09:26:02Z")

</div>

Hi @lars.bergh.hvidsten ,

To use modules without relying on a CDN, you have a couple of options. If the library is available via a CDN, you can technically use async import like this:

```auto
(async () => {
  const THREE = await import('https://cdnjs.cloudflare.com/ajax/libs/three.js/0.169.0/three.cjs');
  // Your code here
})();

```

If the module isn’t available on a CDN, you could consider bundling it into a file (e.g., using esbuild, webpack, or another bundler). You can then add this file as a Resource File in Create and use it as a standard resource in a Coded Component. This gives you more control and removes the dependency on an external CDN.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![lars.bergh.hvidsten](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/lars.bergh.hvidsten/32/2486_2.png) [@lars.bergh.hvidsten](https://community.appfarm.io/u/lars.bergh.hvidsten)\
**Post date:** [November 4, 2024, 2:29pm UTC](https://community.appfarm.io/t/using-modules-in-coded-componen/1470/3 "2024-11-04T14:29:15Z")

</div>

Thanks! I will test this out as soon as i have time 🙂
