Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where do I put static files in my React.JS app?

I ran create-react-app and I got the usual structure with public, src and the javascript files. All fine.

Now I want to add Bootstrap3 to this, but I want to add the normal css/js/font folders instead and create my own components that uses Bootstrap.

The question is; where do I put the files?
Inside the public folder, or in the src?

And I assume I simply refer to them the normal way by adding the <script> and the <link> tags in the public/index.html?

Thanks.

like image 705
vwrynn Avatar asked Feb 05 '26 20:02

vwrynn


1 Answers

This is from create-react-app documentation.

Inside index.html, you can use it like this:

<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">

Only files inside the public folder will be accessible by %PUBLIC_URL% prefix

So, you can add your css inside the public folder, and then add it using tag with the url prefix with %PUBLIC_URL%

like image 140
Dat Tran Avatar answered Feb 07 '26 10:02

Dat Tran



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!