Flags

Flags are a way to pass values into Elm on initialization. guide

Common uses are passing in API keys, environment variables, and user data. This can be handy if you generate the HTML dynamically. They can also help us load cached information in this `localStorage` example github .

# Flags in HTML The HTML is basically the same as before, but with an additional `flags` argument to the `Elm.Main.init()` function.

flags

In this example we are passing in the current time in milliseconds, but any JS value that can be JSON decoded can be given as a flag.

<html> <head> <meta charset="UTF-8"> <title>Main</title> <script src="main.js"></script> </head> <body> <div id="myapp"></div> <script> var app = Elm.Main.init({ node: document.getElementById('myapp'), flags: Date.now() }); </script> </body> </html>

**Note**: This additional data is called “flags” because it is kind of like command line flags. You can call `elm make src/Main.elm`, but you can add some flags like `--optimize` and `--output=main.js` to customize its behavior. Same sort of thing.

index.html

https://wiki.ralfbarkow.ch/assets/flags/index.html