Recommended approach to front-end hosting with Ions?

I’m developing a single page web app which I’ve been running locally using a simple ring app to serve the initial page and route API requests from the front end.

I’m intending to use Datomic Cloud and Ions for production. I can see it’s straightforward enough to set up lambdas for the API endpoints, but I’m wondering if there is a recommended approach for serving the app in the first place, and for handling sessions.

As things stand I’m using cookie based sessions, and I have a bunch of additional routes for sign-in/out, forgot password etc.

Is there a recommended way to deploy this? It would be great if I don’t need any additional Clojure-capable hosting in addition to Ions. Maybe that would mean reorganising into more of a strict SPA, with only static HTML+JS (cljs) and something like JWT for auth?

1 Like

I would go for:

  • Deploy the HTML as a static site on AWS S3.
  • Deploy the Ions and serve them using Lambda + API Gateway
  • Implement authentication and data functions in the static site with Javascript/ClojureScript (or your favorite JS flavor) to call the HTTP API.

With this setup, you could leverage Cognito for authentication, which is closely integrated with API gateway. Or you could just roll your own JWT authentication.

This is exactly what we’re doing

1 Like

Firebase hosting + authentication is another good solution; that’s what I’ve been using.

1 Like

Another +1 for static site on S3+Cloudfront, Ions, JS/CLJS to call buddy JWT auth endpoints. Bonus: GraphQL endpoints on Lacinia+Pedestal. That’s our company’s stack.

1 Like

Thanks for the advice. I’ll probably switch to HTML on S3 at some point, but for now it will be convenient to stick with the mini ring app I already have. @jacob I discovered how to do this from your post [1]. At first I thought it looked weird that you were directly ionizing a ring handler function, which would imply that the request object is compatible. I later found this doozy hiding away in the docs for Web ions [2]:

The input and output maps are mostly compatible with the Clojure Ring Spec, and many web applications should be able to run unmodified as web ions.

So Ions CAN run ‘regular’ web apps as well as SPAs. That fact doesn’t seem to get a mention anywhere prominent.

[1] Building a CRUD app with Datomic Cloud Ions
[2] Ions Reference | Datomic

1 Like