Fireship · @fireship

Tauri in 100 Seconds

Uploaded May 6, 2022 · Length 2:40

Tauri in 100 Seconds

Summary

towri toolkit for building native desktop apps with web tech and rust backend

  • towri
  • native desktop apps
  • rust backend
  • javascript framework
  • cross-platform apps

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    towri a toolkit for building native

  2. 0:02

    desktop apps with rented web

  3. 0:04

    technologies and a lightweight rust back

  4. 0:06

    end it allows you to use your favorite

  5. 0:08

    javascript framework to design a ui then

  6. 0:10

    package it for mac os windows and linux

  7. 0:12

    from a single code base since the dawn

  8. 0:14

    of time javascript developers have been

  9. 0:16

    searching for the perfect way to build

  10. 0:18

    cross-platform apps for the last decade

  11. 0:20

    electron has been the leader in this

  12. 0:21

    space which provides a back-end in

  13. 0:23

    node.js and a front-end with the

  14. 0:24

    chromium browser the main criticism of

  15. 0:26

    this approach is that it results in a

  16. 0:28

    very large executable file that consumes

  17. 0:30

    a lot of memory on the machine towri

  18. 0:32

    takes a different approach by replacing

  19. 0:34

    node.js with rust and chromium with

  20. 0:36

    libraries like tau and rye to provide a

  21. 0:38

    lightweight webview the end result is a

  22. 0:40

    smaller bundle size and more efficient

  23. 0:42

    memory consumption it also takes

  24. 0:44

    security very seriously and provides an

  25. 0:46

    isolation pattern to prevent untrusted

  26. 0:48

    scripts from accessing the backend from

  27. 0:50

    a webview the towery api provides a

  28. 0:52

    secure way to access native

  29. 0:54

    functionality like the file system http

  30. 0:57

    and system notifications it's secure by

  31. 0:59

    default and the only way for the front

  32. 1:01

    end to call back and code is when the

  33. 1:02

    developer explicitly allows it to get

  34. 1:04

    started install rust nodejs then create

  35. 1:07

    a new towry app choose your favorite

  36. 1:09

    javascript framework to build the front

  37. 1:11

    end it looks identical to a web project

  38. 1:13

    except for the source towry directory

  39. 1:15

    this is the back end for your native

  40. 1:17

    desktop app inside of which you'll find

  41. 1:19

    icons that will be displayed when the

  42. 1:20

    app is installed the icons are

  43. 1:22

    referenced in the tower config file

  44. 1:24

    which also contains important

  45. 1:25

    information like the bundle identifier

  46. 1:27

    as well as build settings for mac os

  47. 1:30

    windows and linux now the entry point

  48. 1:31

    for your back end is in the main.rs file

  49. 1:34

    from here we can customize the

  50. 1:35

    experience on the native operating

  51. 1:37

    system by importing the menu types we

  52. 1:39

    can create a custom native menu that

  53. 1:41

    will work seamlessly on all platforms in

  54. 1:44

    addition we can define code and rust

  55. 1:46

    that can then be invoked from the

  56. 1:47

    javascript front end and it has its own

  57. 1:49

    custom event system that allows complex

  58. 1:51

    message passing from the front end to

  59. 1:53

    the back end and vice versa now in the

  60. 1:55

    front end code a variety of native apis

  61. 1:57

    can be accessed with javascript for

  62. 1:59

    example we might import right file from