Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

lirone's avatar

Install Bootstrap 5 using NPM or Composer ?

Hi,

I would like to migrate my theme from Bootstrap 4 to Bootstrap 5.

I found out that I had difficulties to get the difference between composer and npm.

On the documentation, I can install Bootstrap 5 in two ways:

composer require twbs/bootstrap:5.0.1

Or using npm

npm install bootstrap

or using CDN

So far I know that Composer is for PHP package, NPM for JS package but in this case how to choose ? what is the most convenient way and especially a way that makes sens ?

If you could give me an insight, it would be great.

Thank you

0 likes
4 replies
tisuchi's avatar

@lirone If you don't customize hugely, and just use bootstrap simply calling the classes in your div, I believe the easiest way would be to use CDN.

Now, if you compare between using composer and npm, I would recommend that, use NPM because:

  • CSS framework uses for frontend rendering. So, good practice would be to use JS dependency manager.
  • If you use NPM, it will be easy for you to customize in the future.
1 like
lirone's avatar

Thank you for your concise answer !

martinbean's avatar

Install Bootstrap using NPM. I have no idea why they’d offer it as a Composer package when Composer is for installing PHP packages.

1 like
lirone's avatar

It confused me as well. Thank

Please or to participate in this conversation.