IF.js is a JS library for making interactive fiction/CYOA books on the web.
You can see an example of it here, you can also see the code for that in the index.html file. The actual code for the library is in if.js and to import it you can do:
<script type="module" src="https://cdn.jsdelivr.net/gh/AverseABFun/IF.js/if.js"></script>And you should be fine! Note that IF.js requires that the localstorage value gameVars be available and not used for anything else. Documentation is being worked on, but as of now I suggest looking at the example(and it's code) and at the library code itself, which is pretty basic.