Fireship · @fireship

Capacitor - Five Apps in Five Minutes

Uploaded April 2, 2018 · Length 6:50

Capacitor - Five Apps in Five Minutes

Summary

Building a simple JavaScript app with capacitor, a new library from the ionic team that allows web technologies to interact with native SDKs, and deploying it to five platforms: iOS, Android, Windows, Mac OS, and the web.

  • capacitor
  • ionic
  • javascript
  • hybrid apps
  • cross-platform apps
  • progressive web apps
  • native apps

Transcript preview

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

  1. 0:00

    [Music]

  2. 0:02

    over the next five minutes we'll build a

  3. 0:04

    simple JavaScript app then compile its

  4. 0:06

    code for iOS Android Windows desktop Mac

  5. 0:09

    OS and the web to make this possible

  6. 0:12

    we'll be using a new library from the

  7. 0:13

    ionic team called capacitor if you've

  8. 0:16

    built hybrid apps in the past you're

  9. 0:17

    probably familiar with Apache Cordova

  10. 0:19

    which allows web technologies to

  11. 0:21

    interact with native SDKs capacitor is a

  12. 0:24

    replacement for Cordova that puts

  13. 0:26

    progressive web apps on the same plane

  14. 0:28

    field as native apps so you don't need

  15. 0:30

    to constantly check which platform

  16. 0:31

    you're on you just write your code once

  17. 0:33

    and it should work across all platforms

  18. 0:35

    if you're new here make sure to LIKE and

  19. 0:37

    subscribe and if you're interested in

  20. 0:39

    building cross-platform apps consider

  21. 0:41

    upgrading to a pro membership to get

  22. 0:42

    access to my ionic native with firebase

  23. 0:44

    course before we get started I do need

  24. 0:47

    to point out that capacitor is just an

  25. 0:49

    alpha release at this point so it's not

  26. 0:51

    stable enough to use in production and

  27. 0:52

    it's API is likely to change in the

  28. 0:54

    coming months and one other thing to

  29. 0:56

    keep in mind is that this is a

  30. 0:58

    standalone tool so you can use it with

  31. 1:00

    any JavaScript framework or just plain

  32. 1:02

    JavaScript if you wanted to for this

  33. 1:04

    demo I'm using angular but not the ionic

  34. 1:06

    version of angular just a plain CLI app

  35. 1:09

    go ahead and open up the app in your IDE

  36. 1:11

    and then install the capacitor CLI we

  37. 1:15

    can just copy the command from the docs

  38. 1:16

    and then run it from the terminal that

  39. 1:18

    should install it in your project and at

  40. 1:20

    the time of this video we're running

  41. 1:21

    version 1.0 alpha 32 then next thing

  42. 1:25

    we'll do is initialize our app by

  43. 1:26

    running an NP X cap in it and you can

  44. 1:29

    give the app name then the package ID is

  45. 1:32

    important for mobile apps it should

  46. 1:34

    follow a format of calm brand name dot

  47. 1:37

    project name the only thing that's doing

  48. 1:39

    at this point is adding this capacitor

  49. 1:41

    config JSON file to the root of your

  50. 1:43

    project you want to go in here and

  51. 1:45

    change the web directory to dist because

  52. 1:48

    an angular we compile our code to the

  53. 1:50

    dist folder now let's make sure

  54. 1:52

    everything's working properly by

  55. 1:54

    building our app with ng build prod then

  56. 1:57

    we'll serve the app with capacitor by

  57. 1:59

    running NP x cap serve and that's going