Skip to content
Ethosa edited this page Jun 6, 2023 · 5 revisions

Single Page Application

Basic Code of main.nim

import happyx

appRoutes("app"):  # "app" is id of application root element in HTML
  "/":
    "Hello, world!"

Basic Code of main.html

...
<body>
  <div id="app"></div>
  <script src="main.js"></script>
</body>
...

Compilation

nim js main

public Folder Usage

Project structure:

project/
├─ src/
│  ├─ public/
│  │  ├─ hello.png
│  ├─ main.nim
├─ README.md

main.nim or any other nim file

import happyx

appRoutes("app"):
  "/":
    tImg(src = "public/hello.png")
Clone this wiki locally