DEV Community

Discussion on: So you want to stand up your own instance of DEV? (help thread)

Collapse
 
pim profile image
Pim • Edited

I have a question that I didn't know where else to ask. How exactly does dev.to produce it's SPA-like navigation? I can see it's getting the document using ajax, handled by the service worker if it's cached. But what mechanism loads the new doc body? Is it just a vanilla JavaScript injection? How are the navigation actions intercepted on the client-side?

Collapse
 
ben profile image
Ben Halpern

Here's where the code is, which is quite crappy and messy to be honest:

github.com/thepracticaldev/dev.to/...

We basically take the server response and replace the page, but we only take the body element. The nav bar and footer and basic template. But as far as the app's logic outside of this context is concerned, it's pretty much a server-rendered app.

We basically use a hacked up version of InstantClick to make this happen.