Day 10: Optimizing and Publishing Your React Native + Phaser Game
Youโve made it to Day 10! ๐
Today, weโll prepare your cross-platform mobile game built with React Native and Phaser for production: optimize performance, make it responsive, and finally, package it for publishing on iOS and Android using Expo.
๐ง What Youโll Learn
- How to optimize Phaser for mobile performance
- How to make your game scale on any screen size
- How to bundle assets and game HTML in a WebView
- How to build and publish your game using Expo EAS
๐ Step 1: Make Phaser Canvas Responsive
Update your Phaser config to use full width/height dynamically:
const config = {
type: Phaser.AUTO,
scale: {
mode: Phaser.Scale.FIT,
autoCenter: Phaser.Scale.CENTER_BOTH,
width: window.innerWidth,
height: window.innerHeight,
},
physics: {
default: 'arcade',
arcade: { debug: false }
},
scene: [MenuScene, GameScene, PauseScene, GameOverScene]
};
This makes your game canvas responsive across all device sizes.
๐๏ธ Step 2: Inline and Minify Your Game HTML (Optional)
You can:
- Combine assets/scripts into a single
game.html
- Minify using https://html-minifier.com
- Cache resources via CDN (e.g. Phaser, images, audio)
Place your game.html
in assets/phaser/game.html
(or bundle it remotely via HTTPS for Android ease of use).
๐ Step 3: Use WebView Correctly in React Native
In your App.js
:
import React from 'react';
import { WebView } from 'react-native-webview';
import { Platform } from 'react-native';
export default function App() {
const source = Platform.select({
ios: require('./assets/phaser/game.html'),
android: { uri: 'https://yourcdn.com/game.html' }, // Or use local asset workaround
});
return (
<WebView
originWhitelist={['*']}
source={source}
javaScriptEnabled
domStorageEnabled
allowsFullscreenVideo
style={{ flex: 1 }}
/>
);
}
โ ๏ธ For Android local file access, you’ll need to manually copy files into the
android/app/src/main/assets/
folder. Alternatively, serve it via HTTPS.
๐ฆ Step 4: Build for Android and iOS with Expo
Use Expo EAS Build for production builds.
1. Install EAS CLI:
npm install -g eas-cli
2. Configure your project:
eas build:configure
3. Build the app:
eas build --platform android
# or
eas build --platform ios
Follow prompts to create .apk
or .ipa
files.
๐ฑ Step 5: Test & Submit
- Test on real devices via Expo Go and downloaded APKs
- Create developer accounts on Google Play Console and App Store Connect
- Submit your game to the stores for review
โ What Youโve Achieved
- Built a fully playable, mobile-optimized Phaser game
- Packaged it inside a React Native app using WebView
- Added polish: music, animations, pause/resume, levels, leaderboard
- Learned to publish for Android and iOS using Expo + EAS
๐ Series Complete
You now have a production-ready, cross-platform mobile game built entirely with React Native and Phaser โ ready to entertain users on both Android and iOS!
Looking for more?
๐ Build in-app purchases, multiplayer, or convert your WebView game into a standalone HTML5 browser game.
Happy game dev! ๐ฎ๐