Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Bootstrap on Vapor

I am new to web development and couldn't find a clear answer.

Is it possible to use Bootstrap in Vapor with Swift 3?

like image 623
NDM - Mobile DEV Avatar asked Jan 22 '26 09:01

NDM - Mobile DEV


1 Answers

Yes, you can use Bootstrap. You will either:

  • Add the CDN links to your template files, i.e. .leaf files, which are in the Resources/Views/ folder, or
  • Download the Bootstrap files and add the CSS, JS, fonts, etc. to the Public/ folder which can be accessed by all the pages.

For the first suggestion, you could add the CDN links to your base.leaf, like this:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
    #import("head")
</head>
    <body>
        #import("body")
    </body>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</html>

For the second suggestion, you would place the files in here:

enter image description here

Then access the files like this:

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/styles/{CSS-FILE-NAME}">
    #import("head")
</head>
    <body>
        #import("body")
    </body>
    <script src="/{JS-FILE-NAME}"></script>
</html>
like image 180
Caleb Kleveter Avatar answered Jan 25 '26 08:01

Caleb Kleveter



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!