# Creating a capacitor library as opposed to an app?

**URL:** <https://forum.ionicframework.com/t/creating-a-capacitor-library-as-opposed-to-an-app/224299>\
**Category:** Ionic Framework\
**Created:** [June 17, 2022, 5:30pm UTC](https://forum.ionicframework.com/t/creating-a-capacitor-library-as-opposed-to-an-app/224299 "2022-06-17T17:30:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![npepperoni](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/npepperoni/32/141798_2.png) [@npepperoni](https://forum.ionicframework.com/u/npepperoni)\
**Post date:** [June 17, 2022, 5:30pm UTC](https://forum.ionicframework.com/t/creating-a-capacitor-library-as-opposed-to-an-app/224299/1 "2022-06-17T17:30:34Z")

</div>

I’d like a bit of guidance on how to structure this thing i’m trying to make. I’m trying to make a library that can be used by other apps via ionic web portals, however I also need to be able to use capacitor plugins from inside the web code of this library.

The documentation around capacitor suggests its only intended for taking a web app and compiling it to native apps, but in this case I just want my library to be usable by other web apps/native apps, so there is no web app in my product. I just want capacitor in the sense that I want to use plugins for things like bluetooth connections in my library, I dont need/want to compile down to runnable native applications.

---

<div class="post-metadata">

**Author:** ![mikrochipkid](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mikrochipkid/32/116956_2.png) [@mikrochipkid](https://forum.ionicframework.com/u/mikrochipkid)\
**Post date:** [June 18, 2022, 2:47pm UTC](https://forum.ionicframework.com/t/creating-a-capacitor-library-as-opposed-to-an-app/224299/2 "2022-06-18T14:47:47Z")

</div>

> **[Micro Frontend Architecture for Mobile Web Apps - Ionic Portals](https://ionic.io/portals?gclid=CjwKCAjw77WVBhBuEiwAJ-YoJMQAJ2So0kKRG-2ZiPrmZbY0s-_QvBTzXVZ-sa3DS4bEaWSLUcE-BxoCjrMQAvD_BwE)**
>
> Portals allow teams to build, test, and ship in parallel with embedded web experiences in native mobile apps. Read more about Ionic micro frontend architecture.

---

<div class="post-metadata">

**Author:** ![npepperoni](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/npepperoni/32/141798_2.png) [@npepperoni](https://forum.ionicframework.com/u/npepperoni)\
**Post date:** [June 19, 2022, 3:50am UTC](https://forum.ionicframework.com/t/creating-a-capacitor-library-as-opposed-to-an-app/224299/3 "2022-06-19T03:50:16Z")

</div>

Portals is what we were already looking at for the native solutions (basically make a very simple web app which essentially just consumes our library), but we were still trying to figure out how to make something similar for web based consumers of this component library. The answer seems to actually be pretty simple though: we didn’t realize that if the consuming app had registered a capacitor plugin, any module inside of it can also leverage that plugin, which solves my initial question.

So for the web consumer case (assuming the web consumer is itself a capacitor app, which it would be in our case) we just need to document that they need to register the appropriate plugins that our library needs. With that, we can guarantee (assuming our consumers have met requirements) that whether the native app be actually a native app consuming our web portal, or a native app that is compiled from a web app via capacitor which itself consumes our library, we will have the plugin implementation in place and we can use it from within our library components.
