To upload a Progressive Web App (PWA) to the Google Play Store, you'll need to wrap your PWA within a native Android application container using a framework such as Capacitor or Bubblewrap. We will first go over general steps to follow using Capacitor, and then cover Bubblewrap, both which integrate well with frameworks like Next.js.
Also look at galaxy.dev for a great Capacitor guide!
manifest.json
and a service worker in place.If you haven't done this already, you'll need to install Capacitor in your Next.js project.
npm install @capacitor/core @capacitor/cli
npx cap init
You will be prompted to enter your app name, app package (e.g., com.example.app
), and other details.
In your project directory, run the following command to add the Android platform:
npx cap add android
This creates an android
directory in your project.
capacitor.config.ts
Open the capacitor.config.ts
file and configure the settings for your app, including the server URL (the URL of your PWA):
const config = {
appId: 'com.example.app',
appName: 'MyPWA',
webDir: 'out', // or the build directory of your Next.js app
bundledWebRuntime: false,
server: {
url: 'https://your-pwa-url.com',
cleartext: true // set this if your server uses HTTP for testing (not recommended for production)
},
};
export default config;
Build your Next.js app for production:
npm run build
npm run export
Make sure the output directory (e.g., out
) matches what you set in capacitor.config.ts
.
Sync the changes to the native Android project:
npx cap sync android
Open the Android project in Android Studio:
npx cap open android
AndroidManifest.xml
file and ensure that your PWA is set up correctly.Build
> Generate Signed Bundle/APK
.Once your app is submitted, you’ll receive updates about the review process via the Google Play Console. Make sure to monitor feedback and make any necessary changes based on user reviews or Play Store policies. Once approved, your PWA will be available on the Google Play Store for users to download and install.
You can package your Progressive Web App (PWA) using Bubblewrap to create a native Android application that you can publish on the Google Play Store. Bubblewrap is a command-line tool that allows you to generate an Android app package (APK) from your PWA based on the Trusted Web Activity (TWA) model.
manifest.json
file and service worker.First, make sure you have Node.js installed on your machine. Then, install Bubblewrap globally using npm:
npm install -g @bubblewrap/cli
Navigate to your project's directory and initialize Bubblewrap:
bubblewrap init --manifest=https://yourdomain.com/manifest.json
This command initializes a new Bubblewrap project based on the manifest file of your PWA.
This --manifest
flag specifies the URL to the PWA's manifest.json
file. The manifest file contains metadata about the PWA, such as its name, icons, start URL, theme colors, and display settings. Bubblewrap fetches this manifest file to set up the Android application in accordance with the PWA's specifications.
Replace https://your-pwa-url.com
with the actual URL of your PWA. This command will create a directory with the necessary files and configuration.
During the initialization, you will be prompted to enter various details about the app, such as:
com.example.app
)Make sure to provide accurate information, as this will be used in your AndroidManifest.xml
.
Once you've configured your app, you can build the APK using the following command:
bubblewrap build
Bubblewrap will use the configuration and package your PWA into a native Android app.
After the build is complete, you can find the generated APK in the /app/
directory of your project. You can install this APK on an Android device to test it before submission.
To upload your APK to the Google Play Store, it must be signed. You can sign it using Android Studio or the command line. If using Android Studio:
Build
> Generate Signed Bundle/APK
.More Details on Signing Your App
Now that your APK is signed, you can upload it to the Google Play Console:
Once your app is successfully submitted and approved, it will be available for users to download from the Play Store.
After building the APK using Bubblewrap, you might want to open the Android project in Android Studio to perform additional configurations or test the app:
Open Android Studio:
Open an Existing Project:
bubblewrap init
step).app/
.Explore and Edit the Project:
AndroidManifest.xml
, add additional resources, modify the layout, or undertake any other development tasks.Build and Run:
Run
> Run 'app'
or click the green play button.Debug the App:
Unable to find Gradle tasks to build error
make sure that you have hypervisor activated for Windows on android studiohttps://developer.android.com/studio/publish/app-signing - shows you how to sign your app
https://medium.com/@imvinojanv/the-complete-guide-to-building-progressive-web-apps-with-next-js-f37b4bb878cd - This is a good Guide to making PWAs on NextJs
Bubblewrap Git Repo - this link isn't very helpful but they provide a link to: [PWA Builder]
(https://www.pwabuilder.com/) which seems to be a free cloud service that does the same thing Bubblewrap does without using VSCODE to do it
Lessons Learned: Bubble wrap installs the JDK SDK once but doesnt always display the same message if its already installed But this might help you troubleshoot that step