📄
BoltUI Docs (Preview)
  • Getting Started
    • Introduction
    • Installing Bolt
    • Hello World
  • Understanding Bolt
    • Creating UI
    • Components
    • Properties & Events
    • Styles
    • Custom Components
    • Reactivity
    • Component Lifecycle
    • Routing
  • API Reference
    • index
      • State
      • Component
      • render
      • attribute
      • event
      • onLoad
      • onRemove
      • id
      • Class
      • When
    • components
      • Link
      • AppLink
      • GenericElement
    • events
      • onGenericEvent
    • boltrouter
      • Router
      • AppRouter
      • Url
      • Navigate
      • AppNavigator
  • Future
    • Server Side Rendering
    • Multi-Platform
Powered by GitBook
On this page
  1. Getting Started

Hello World

Creating a Hello World using Bolt

The first thing any developer does when learning a new piece of technology is to greet the world, and Bolt is no exception.

From the previous page, I assume you have learned to create a Bolt Project. Let's create a new project called hello-world

$ npm create vite@latest
    ? Project name: > hello-world
    ? Select a framework: >
    >    Vanilla
    ? Select a variant: >
    >    Javascript
$ cd hello-world
$ npm i
$ npm i boltjs-preview

Now, you will see a main.js file. Open the file, and delete all the code inside that file, and write the code given below:

//in main.js
import { render } from 'boltjs-preview'
import { p } from 'boltjs-preview/components'

function HelloWorld() {
    return p("Hello World")
}

render("app", HelloWorld())

Now you will also see a index.html file. Open that file and add the code given below

<!--index.html-->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale="1.0" />
        <title>Hello World</title>
    </head>
    <body>
        <div id="app">
        </div>
        <script type="module" src="/main.js"></script>
    </body>
</html>

Now you are ready to test your app for the first time! Run the following command to start the server

$ npm run dev

Now open the browser to the url it points to. usually it is http://localhost:5173

When you open the browser, it should show something like this

Congrats on creating your app! Now you can go ahead and learn exactly how the framework works and how you can use different functions and methods to create amazing apps!

Also if you need to refer the functions, you can always go to the API Reference section of the Bolt Architecture group.

I have also included some codelabs which will guide you to build some apps of different kinds!

PreviousInstalling BoltNextCreating UI

Last updated 2 years ago

BoltUI Hello World