LogRocket Blog

Building progressive web apps using Rust

thumbnail
  • Introduction: This article focuses on building progressive web apps using Rust, showcasing how Rust can be used to develop the business logic for a PWA that can be combined with a JavaScript/TypeScript frontend, offering a versatile solution that works across platforms.

  • Setting Up SurrealDB and Networking Layer: The tutorial introduces SurrealDB, a multi-modal database that can work with cloud files or in-browser using IndexedDB. It touches on using Nostr for networking capabilities and integrating logging with the log and web-sys crates for a seamless development experience.

  • Wasm Build Pipeline: The article explains the process of building a Wasm binary for the Rust code using the wasm-pack tool, including necessary configurations and flags. It highlights the importance of wasm-bindgen and other dependencies for successful compilation to Wasm.

  • Initializing Database and Key Management: A detailed explanation is provided on initializing the database connection and implementing key management functionalities. It covers key generation, persistence logic, and storing keys securely in the database using SurrealDB's API.

  • Encrypting and Storing Messages: The tutorial progresses to encrypting and storing messages and files, starting with defining data types and implementing functions to fetch, decrypt, and serialize messages for use in JavaScript/TypeScript. It emphasizes the serialization of complex data types for compatibility.

By following these steps, developers can build a robust PWA with Rust, leveraging SurrealDB for storage, Nostr for networking, and ensuring data security through encryption and key management functionalities.