Closed
Labels
contentIssues related to the contents of the documentation website
Description
Feature Request
Using Ionic v4 from npm is only supported for frameworks through the framework specific packages. There is no documented way of using @ionic/core from npm directly without CDN. I understand the benefits of the CDN but there are some use cases when this is not possible, like corporate proxies or problems with ad blockers.
Ionic version:
[x] 4.x
Describe the Feature Request
Support using @ionic/core from npm without a framework.
Describe Preferred Solution
Document how to do it and explore if any change in the source code would be needed.
Describe Alternatives
Using the CDN, but it may not be possible for every use case.
Related Code
Additional Context
Reacted by ippei, Luciano Lima, Benjamin Jesuiter, Sámal Rasmussen, redfave and Martin Blom
Metadata
Metadata
Assignees
Labels
contentIssues related to the contents of the documentation website
Type
Fields
No fields configured for issues without a type.
Activity
brandyscarney commentedon Feb 11, 2019
I've moved this issue to the
ionic-docsrepository as it is a request for improved documentation. We have an example of using Ionic from npm in a stencil app here: https://github.com/ionic-team/ionic-stencil-conference-appIt should be fairly similar to use it in a non-stencil project.
camwiegert commentedon Feb 13, 2019
Thinking we should include a section on this page.
brandyscarney commentedon Feb 13, 2019
Agreed. That's a good spot for it.
adrm commentedon Feb 20, 2019
And on top of that, I think that that page @camwiegert mentioned needs to specify that you also need to include ionic stylesheet.
brandyscarney commentedon Feb 20, 2019
Yes @adrm you can include the css bundle or if you prefer to break it up and only include some of the css files they are the following in npm:
Here's more of an explanation on what each file is: https://github.com/ionic-team/ionic/blob/master/angular/BREAKING.md#global-css
coderbuzz commentedon Sep 19, 2019
How to initialise Ionic app manually using Vanilla JS?
Call setupConfig only seems not working.
Need something like
import { setupConfig, init } from '@ionic/core'; init();The following just utilize JSX to generate HTML Elements
ippeiukai commentedon Sep 26, 2019
It would be helpful to have a way for bundling imported @ionic/core with Webpack etc. too.
Right now, the vanilla JS files in dist directory tries to find a script tag with src matching specific filename in DOM tree, and then downloads extra files relative to that src URL. Even if we give up bundling and copy entire dist directory, it’s not pretty with our web framework’s static asset management that wants filename with contenthash.
adrm commentedon Feb 6, 2020
I understand the need for this feature is lower now since we have Ionic packages for several popular frameworks, but you can easily import Ionic web components to be used everywhere, after
npm install @ionic/core, like this:Depending on your setup, you might need to import css in other way. You can also import the bundled files from the CDN but in my case I needed some more control than that, and I would like to control which files are executed in my app, have them version-controlled, and be able to run the app offline for development.
I think this should be stated on the docs, understanding that this is not a very frequent way to use Ionic but it helps demonstrating that Ionic is no longer tied to any framework and you can even use it in a framework agnostic way.
coderbuzz commentedon Feb 13, 2020
Hi @adrm , thank you for the hints. Unluckily I still got error rendering simple button:
uriannrima commentedon Feb 26, 2020
Can't say how much I'm grateful for your tip, man. Worked like a charm to me. Thank you so much again.
coderbuzz commentedon Feb 26, 2020
Hi @uriannrima , might you share with us how you get the code working while I got an error?
uriannrima commentedon Feb 27, 2020
Here is what I have and what I did:
I've an Vue application that I don't want to use @ionic/vue but use directly the web components without something in between. Since it is SSR App I've two entry points, one for client side and other for server. I don't want the web components in server so I've added the example given by @adrm only in the client entry just after the Vue app bootstrap, like so:
The ionic.scss imports the ionic styles like @brandyscarney recommend.
In entry-client I have:
You may ignore most of what is written, the only important thing is the setup ionic after the vue mount. As I register the components only after vue mounts maybe it solves something that is happening to you @coderbuzz.
I'll try to create a simple raw JavaScript app with webpack to see if also happens to me.
coderbuzz commentedon Feb 27, 2020
2 remaining items
touletan commentedon Feb 28, 2020
I'm getting and error mentionning that IonicConfig is not found in @ionic/core ????
DamianoP commentedon Mar 2, 2023
The proposed solution doesn't work anymore with the current version of Ionic
LeviticusMB commentedon Jan 27, 2025
I've spent a lot of time recently — too much — trying to bundle
@ionic/corein a fresh Vite+Lit project, but I just couldn't make it work. And there seem to be next to nothing about consuming plain Ionic (without any framework bindings) with Vite on the web either ...There really ought to be a section in the Ionic Packages & CDN page about how to bundle Ionic with popular bundlers such as Vite, Rollup and Webpack at least.
Anyway, adding
to the Vite config did make the dev server work, but when building for production, all components (like
ion-app_8.entry.jsetc) are missing from theassetsfolder and fails to load. I tried to copy them manually fromnode_modules/@ionic/core/dist/esm/, but that just lead to more weird runtime exceptions.In the end, I gave up on lazy-loading the Ionic components (including the
optimizeDeps.excludehack). Instead, I use the followingbuild-ionic-loader.cjsscript to create asrc/ionic-loader.tsfile to manually define the components I use, and which I then import in the Vite project.I can run this script as
to only bundle the Ionic components I actually use in my project. And then I just bootstrap Ionic as usual, except that I also import the
src/ionic-loader.tsto "preload" the components I use.brandyscarney commentedon Oct 13, 2025
Hey everyone! We just added a section for JavaScript with the following guides:
The Quickstart uses Vite and lazy loaded components. We would like to add more guides to this section like the framework integrations but this is a start!
I will leave this issue open so we can get a section added for it here: https://ionicframework.com/docs/intro/cdn
LeviticusMB commentedon Oct 15, 2025
@brandyscarney, I don't get it ... I followed the the quickstart instructions exactly and yeah the dev server works but
npm run build && npm run previewcertainly doesn't.assets/ion-route_4.entry.jsandassets/ion-app_8.entry.jscannot be loaded by the browser. Now, if I changevite.config.jsto:the above Ionic files (and many more) can be loaded but the page is still just blank with loads of weird
DOMException: String contains an invalid characterin the console. And, of course, Ionic is not minified/processed in any way.npm 10.9.2, node v23.11.0,
@ionic/core8.7.6,vite7.1.7,vite-plugin-static-copy3.1.3.brandyscarney commentedon Nov 12, 2025
Hi @LeviticusMB, thank you for the feedback! I have updated the guide on this PR and you can preview the changes here: https://ionic-docs-git-docs-quickstart-updates-ionic1.vercel.app/docs/javascript/quickstart
I confirmed that this is now working for
npm run dev,npm run build && npm run previewand Capacitor. Let me know if you notice any other issues!docs(intro): update packages & CDN to redirect to other guides (ionic…
translation(jp): 20251122 update (#4334)
translation(jp): 20260308 update (#4426)
DeJy commentedon May 25, 2026
@brandyscarney latest version of viteStaticCopy needs rename: { stripBase: true },