simplesinglepage can create simple single page apps. You just have to do the following:
route("contact", document.getElementById("contactFormTemplate").innerHTML); // you can have multiple routes; the second argument is a string; the second argument is everything inside <html>
and for the HTML:
<template id="contactFormTemplate">
<h1>Contact</h1>
<form action="mailto:example@example.com">
<input type="text" name="subject" />
<br />
<textarea name="body"></textarea>
</form>
</template>
<a href="?contact">Contact Us</a>
<!-- You can have extra GET paramaters -->
Although we're using GET paramaters, no server is required (other than your static server), because it uses URLSearchParams
and window.location.search
, and both are only available client side.
Originally, I wanted to use a #
, but those are hard to work with, so I'm using a query paramater because it's easier to develop with.