CapacitorJS for PWA/TWA

944 views Asked by At

I'm planning to make a Webapplication for Web with should also work as PWA and TWA (on iOS and Android).

Now i'm evaluating if i can use some features like camera, geolocation, accelerometer, notifications and some more.

I tryed to make a demo project with CapacitorJS and wondering why i need to add native platforms to target and why there is a seperate folder "android".

I just want to create one Website/PWA which should run as Website, on iOS and Android (in Browser) and not start a second or third seperate project for iOS and Android.

How can i use CapacitorJS to target the Web and when the website is called from iOS/Android than the native functions from iOS/Android are used?

1

There are 1 answers

0
jcesarmobile On BEST ANSWER

You can't use the native code in a TWA or PWA, that's the whole point of the native platforms, to use native code when the web don't have a proper equivalent.

With Capacitor you use the same code for web, native iOS and native Android, is up to you if you want to use native iOS and native Android or not, but to use it you have to publish the app on the App store and Play store, the PWA will always use web APIs.