This repository provides bindings for Capacitor plugins to be used with WebSharper, enabling seamless integration of Capacitor functionality into WebSharper projects.
WebSharper Capacitor aims to bring the power of Capacitor plugins to WebSharper developers by providing F# bindings for various Capacitor plugins. These bindings facilitate the creation of modern, cross-platform web and mobile applications with WebSharper.
The following Capacitor plugins have bindings in this repository:
- BiometricAuth - @aparajita/capacitor-biometric-auth
- ActionSheet - @capacitor/action-sheet
- AppLauncher - @capacitor/app-launcher
- App - @capacitor/app
- BackgroundRunner - @capacitor/background-runner
- BarcodeScanner - @capacitor/barcode-scanner
- Browser - @capacitor/browser
- Camera - @capacitor/camera
- Clipboard - @capacitor/clipboard
- Cookies - @capacitor/core
- Device - @capacitor/device
- Dialog - @capacitor/dialog
- Filesystem - @capacitor/filesystem
- Geolocation - @capacitor/geolocation
- GoogleMaps - @capacitor/google-maps
- Haptics - @capacitor/haptics
- Http - @capacitor/core
- InAppBrowser - @capacitor/inappbrowser
- Keyboard - @capacitor/keyboard
- LocalNotifications - @capacitor/local-notifications
- Motion - @capacitor/motion
- Network - @capacitor/network
- Preferences - @capacitor/preferences
- PushNotifications - @capacitor/push-notifications
- ScreenOrientation - @capacitor/screen-orientation
- ScreenReader - @capacitor/screen-reader
- Share - @capacitor/share
- SplashScreen - @capacitor/splash-screen
- StatusBar - @capacitor/status-bar
- TextZoom - @capacitor/text-zoom
- Toast - @capacitor/toast
- Watch - @capacitor/watch
Before starting, ensure you have the following:
- Node.js and npm installed on your machine.
- Capacitor set up for managing cross-platform apps.
- WebSharper used for building F#-based web applications.
- A project structure ready to integrate Capacitor and WebSharper.
-
Initialize a Capacitor project:
npm init # Initialize a new Node.js project npm install # Install default dependencies npm i @capacitor/core # Install Capacitor core library npm i -D @capacitor/cli # Install Capacitor CLI as a dev dependency npx cap init "YourApp" com.example.yourapp --web-dir wwwroot/dist # Initialize Capacitor in the project
-
Add the WebSharper Capacitor NuGet package:
dotnet add package WebSharper.Capacitor --version 8.0.0.494-beta1
-
Add Android platform:
npm i @capacitor/android # Install Capacitor Android platform support npx cap add android # Add the Android platform to your project
-
Add iOS platform:
npm i @capacitor/ios # Install Capacitor iOS platform support npx cap add ios # Add the iOS platform to your project
-
Choose and install the Capacitor plugins you want to use. For example, to use the Camera plugin:
npm i @capacitor/camera
-
Build your project:
npm i vite # Install Vite for building your web assets npx vite build # Build your web project with Vite
-
Sync configuration:
npx cap sync # Sync Capacitor configuration and plugins
- Ensure your Capacitor project is correctly configured with
capacitor.config.json
. - The WebSharper Capacitor package provides bindings for seamless integration but still requires Capacitor plugins to be installed via
npm
. - Check out sample usage of plugins in the
WebSharper.Capacitor.Sample
directory.