HTML/JS
Build your first hello world app with standard HTML/JS
This guide will help you build your first highlight app in vanilla JS using Vite.
Tutorial written by Vignesh Aithal
App Setup
In this guide, we will be building a basic app that will print the suggestion text to the screen.
Requirements
- NodeJS
- PNPM
- ViteJS
Create a Vite project
Run below command to create a new Vite project.
Next it we’ll ask you a few fun questions about your app like name, framework, etc. Make sure you select Vanilla JS as the framework.
Run the app
Highlight detects your app ONLY if it is running on PORT 3000. So, make sure you specify --port=3000
when launching your app:
To view your app, you need to enable Developer Mode on Highlight. Here are the steps to do it:
- Open the Highlight app.
- Click “Settings” in the bottom navigation bar.
- Click “Advanced” in the top bar.
- Toggle the switch next to “Developer Mode”.
- A new Local Development app will appear in your pinned apps. Click it.
- You should now see your Vite JS app running inside Highlight.
Add Suggestions Prompt
Next, you need to add a suggestion prompt file which helps you show custom suggestions for your app when users invoke it by hovering over the Highlight icon or by pressing the shortcut key.
To generate suggestions for your app you just need to create a file called suggestion.hbs
.
So create a new file inside your JS app in the public folder: copythat/public/suggestions.hbs
.
Add Highlight APIs
Now we will add Highlight API listeners which will detect when users invoke the app.
Add below code to main.js.
And this code to index.html
The above code detects the suggestion then outputs it.
Great!
Congratulations on creating your first Highlight app!
You’ve now received a concise introduction to Highlight’s capabilities. For a comprehensive understanding of the available API methods, we recommend exploring the Runtime API documentation.
Additionally, we invite you to join our Discord community, where you can interact with our team and fellow developers, as well as seek assistance in developing your application.