'How to add bootstrap 5 and other global packages to a SvelteKit project?

I installed bootstrap using NPM

In a normal svelte project I usualy add bootstrap and other packages, which are used project wide, in the App.ts file. However, in a SvelteKit project there is no main entry point.

So what is the recommended way of adding bootstrap 5 or other packages to SvelteKit globally?

I don't want to use rollup plugins, but rather just want to import it as an module in JavaScript



Solution 1:[1]

You can make a top level __layout and import everything there.

Solution 2:[2]

I add this because this seems to be a good way for adding packages to a SvelteKit app.

https://github.com/svelte-add/svelte-add

If you want to add Bootstrap for example use

npx svelte-add@latest bootstrap

As of date of writing this, there are not alot of packages yet, hopefully that changes in the future.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stephane Vanraes
Solution 2 Red