@joystick.js/ui

index.html

How to configure and use the base HTML file for your Joystick app.

At the root of your app, the index.html file serves as the base HTML file for your entire app. When Joystick server-side renders a page, that page is mounted into the <div id="app"></div> element inside this file. This file is included in the template created for you when you run joystick create <app_name>.

Any global HTML tags that need to be present in the app—such as meta tags for Google Fonts—should be added here.

Example Usage

Base index.html

/index.html

&lt;!doctype html&gt;
&lt;html class="no-js" lang="en"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;title&gt;App&lt;/title&gt;
    &lt;meta name="description" content="A new Joystick app."&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;meta name="theme-color" content="#FFCC00"&gt;
    &lt;link rel="apple-touch-icon" href="/apple-touch-icon-152x152.png"&gt;
    &lt;link rel="stylesheet" href="/_joystick/index.css"&gt;
    &lt;link rel="manifest" href="/manifest.json"&gt;
    ${css}
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div id="app"&gt;&lt;/div&gt;
    &lt;script&gt;
      if ("serviceWorker" in navigator) {
        navigator.serviceWorker.register("/service-worker.js");
      }
    &lt;/script&gt;
  &lt;/body&gt;
&lt;/html&gt;

SSR CSS Target

Inside the template, Joystick anticipates a ${css} placeholder. During a server-side render, Joystick automatically injects the CSS for your component tree into this slot.

If your app is missing its CSS in the browser, double-check that this placeholder is present.

Service Workers

To enable basic Progressive Web App (PWA) support, Joystick’s default index.html template includes a call to register a generic service-worker.js file. This file is stored in the /public folder of your app to make it accessible when index.html is loaded in the browser.

If your app does not require (or you do not want) service workers, you can comment out or delete the <script></script> block wrapping this import.