---
title: "Launching Livebook using LiveView"
description: "Fly.io’s Livebook launcher uses a single LiveView process to deploy a Livebook instance, but temporarily held deployment secrets could be lost when a user refreshed the browser or the server restarted. The secrets, including liveview_password, were sent to deployment and stored in Vault, so the values could not be retrieved; keeping them in a database or Redis also conflicted with avoiding persistent server-side storage. The implementation encrypts the private state with Phoenix.Token.encrypt/4, stores the resulting blob in browser SessionStorage, and uses LiveView hooks and websocket events to restore it through Phoenix.Token.decrypt/4. After recovery, the UI resumes tracking deployment progress, then clears the cached data when deployment succeeds or fails, while closing the tab also clears SessionStorage."
---

# Launching Livebook using LiveView

[Fly.io](https://yomu.fyi/company/fly-io) · Nov 18, 2021

**Type:** Problem & solution

## Summary

Fly.io’s Livebook launcher uses a single LiveView process to deploy a Livebook instance, but temporarily held deployment secrets could be lost when a user refreshed the browser or the server restarted. The secrets, including liveview\_password, were sent to deployment and stored in Vault, so the values could not be retrieved; keeping them in a database or Redis also conflicted with avoiding persistent server-side storage. The implementation encrypts the private state with Phoenix.Token.encrypt/4, stores the resulting blob in browser SessionStorage, and uses LiveView hooks and websocket events to restore it through Phoenix.Token.decrypt/4. After recovery, the UI resumes tracking deployment progress, then clears the cached data when deployment succeeds or fails, while closing the tab also clears SessionStorage.

## Context

The launcher kept private, temporary deployment data only in a LiveView process. A browser refresh, connection problem, or server deployment or restart could cause the UI to lose secrets needed to display the deployment information at the end. A database or Redis server was considered, but retaining that data on the service was undesirable.

## Approach / What changed

The implementation encrypts the private deployment data with Phoenix.Token.encrypt/4 and stores the encrypted blob in the browser’s SessionStorage. LiveView hooks handle store, restore, and clear events between the server and browser. On reload or server restart, the browser sends the data back, the server decrypts it with Phoenix.Token.decrypt/4, and deployment tracking resumes.

## Takeaways

- Phoenix.Token.encrypt/4 both signs the deployment data to prevent tampering and encrypts its contents to keep them private.
- LiveView hooks use websocket events to store encrypted state in SessionStorage and push it back to the server for restoration.
- Cached state is removed from SessionStorage after deployment success or failure, and closing the browser tab clears the session storage as well.

**Tags:** [LiveView](https://yomu.fyi/topic/liveview), [WebSockets](https://yomu.fyi/topic/websockets)

- Source: [Fly.io](https://fly.io/blog/creating-the-livebook-launcher-in-liveview)
- Source URL: https://fly.io/blog/creating-the-livebook-launcher-in-liveview
- Ingested by Yomu: 2026-09-03T01:26:55.373Z

[Read original post](https://fly.io/blog/creating-the-livebook-launcher-in-liveview)
