Skip to content

Commit 98d5e10

Browse files
authored
Mobile release 2025-12-05 (#243)
1 parent f4aabe2 commit 98d5e10

File tree

2 files changed

+101
-49
lines changed

2 files changed

+101
-49
lines changed

resources/views/docs/mobile/2/concepts/authentication.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,18 +74,34 @@ You will likely want to use an OAuth client library in your app to make interact
7474
When initiating the auth flow for the user, you should use the `Native\Mobile\Facades\Browser::auth()` API, as this is
7575
purpose-built for securely passing authorization codes back from the OAuth service to your app.
7676

77-
You should set your redirect URL to `nativephp://127.0.0.1/some/route`, where `some/route` is a route you've defined in
78-
your app's routes that will be able to handle the auth code.
77+
For this to work, you must set a `NATIVEPHP_DEEPLINK_SCHEME` that will be unique for your application on users' devices.
7978

80-
Note that the scheme of the redirect URL in this case is **always** `nativephp://`. This has nothing to do with any
81-
custom deep link scheme you may have set for your app. It is only tied to the `Browser::auth()` session.
79+
```dotenv
80+
NATIVEPHP_DEEPLINK_SCHEME=myapp
81+
```
82+
83+
Then you must define your redirect URL. It should match your scheme and the route in your app that will handle the callback
84+
data.
85+
86+
```php
87+
Browser::auth('https://workos.com/my-company/auth?redirect=myapp://auth/handle')
88+
```
89+
90+
Most services will expect you to pre-define your redirect URLs as a security feature. You should be able to provide your
91+
exact URL, as this will be the most secure method.
92+
93+
How you handle the response in your app depends on how that particular API operates and the needs of your application.
8294

8395
<aside>
8496

85-
Make sure you have good security around your auth service's authentication endpoint. As it will be accessed from many
86-
devices via an API, standard browser security such as CSRF protections will not be available to you.
97+
#### Security
98+
99+
If you're running your own auth service, make sure you have good security around its authentication endpoint. As it
100+
will be accessed by unauthenticated from many devices via an API, standard browser security — such as CSRF protection —
101+
**will not be available** to you.
87102

88-
Ensure you have appropriate rate limiting in place and even consider using an authentication key that you distribute
89-
with your apps. These steps will all help defend the endpoint against abuse.
103+
Ensure you have appropriate **rate limiting** in place and even consider using an **authentication key** that you
104+
distribute with your apps and is solely used to for accessing the authentication endpoint. These steps will all help
105+
defend the endpoint against abuse.
90106

91107
</aside>

resources/views/docs/mobile/2/getting-started/development.md

Lines changed: 77 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,42 @@ If you're familiar with these tools, you can easily open the projects using the
9999
php artisan native:open
100100
```
101101

102+
### Configuration
103+
104+
You can configure the folders that the `watch` command pays attention to in your `config/nativephp.php` file:
105+
106+
```php
107+
'hot_reload' => [
108+
'watch_paths' => [
109+
'app',
110+
'routes',
111+
'config',
112+
'database',
113+
// Make sure "public" is listed in your config [tl! highlight:1]
114+
'public',
115+
],
116+
]
117+
```
118+
119+
<aside>
120+
121+
#### Skip the prompts
122+
123+
If you are tired of prompts, you can run most commands - like `native:run` - with arguments and options that allow you
124+
to skip various prompts. Use the `--help` flag on a command to find out what values you can pass directly to it:
125+
126+
```shell
127+
php artisan native:run --help
128+
```
129+
130+
</aside>
131+
132+
102133
## Hot Reloading
103134

104135
We've tried to make compiling your apps as fast as possible, but when coming from the 'make a change; hit refresh'-world
105-
of PHP development that we all love, compiling apps can feel like a slow and time-consuming process.
136+
of typical browser-based PHP development that we all love, compiling apps can feel like a slow and time-consuming
137+
process.
106138

107139
Hot reloading aims to make your app development experience feel just like home.
108140

@@ -112,69 +144,73 @@ You can start hot reloading by running the following command:
112144
php artisan native:watch
113145
```
114146

115-
You can also pass the `--watch` option to the `native:run` command.
147+
<aside>
148+
149+
#### 🔥 Hot Tip!
150+
151+
You can also pass the `--watch` option to the `native:run` command. This will build and deploy a fresh version of your
152+
application to the target device and _then_ start the watcher, all in one go.
153+
154+
</aside>
116155

117156
This will start a long-lived process that watches your application's source files for changes, pushing them into the
118157
emulator after any updates and reloading the current screen.
119158

120-
Use this in tandem with Vite's own HMR for the platform you wish to test on:
159+
If you're using Vite, we'll also use your Node CLI tool of choice (`npm`, `bun`, `pnpm`, or `yarn`) to run Vite's HMR
160+
server.
121161

122-
```shell
123-
npm run dev -- --mode=ios
162+
### Enabling HMR
124163

125-
npm run dev -- --mode=android
126-
```
164+
To make HMR work, you'll need to add the `hot` file helper to your `laravel` plugin's config in your `vite.config.js`:
127165

128-
This is useful during development for quickly testing changes without re-compiling your entire app. When you make
129-
changes to any files in your Laravel app, the web view will be reloaded and your changes should show almost immediately.
166+
```js
167+
import { nativephpMobile, nativephpHotFile } from './vendor/nativephp/mobile/resources/js/vite-plugin.js'; // [tl! focus]
130168

131-
Vite HMR is perfect for apps that use SPA frameworks like Vue or React to build the UI. It even works on real devices,
132-
not just simulators! As long as the device is on the same network as the development machine.
169+
export default defineConfig({
170+
plugins: [
171+
laravel({
172+
input: ['resources/css/app.css', 'resources/js/app.js'],
173+
refresh: true,
174+
hotFile: nativephpHotFile(), // [tl! focus]
175+
}),
176+
tailwindcss(),
177+
nativephpMobile(),
178+
]
179+
});
180+
```
133181

134182
<aside>
135183

136-
#### Livewire and HMR on real devices
137-
138-
Full hot reloading support for Livewire on real devices is not yet available.
139-
140-
</aside>
184+
#### Two at a time, baby!
141185

142-
### Configuration
186+
If you're developing on macOS, you can run both Android and iOS watchers at the same time in separate terminals:
143187

144-
You can configure the folders that the `watch` command pays attention to in your `config/nativephp.php` file:
188+
```shell
189+
# Terminal 1
190+
php artisan native:watch ios
145191

146-
```php
147-
'hot_reload' => [
148-
'watch_paths' => [
149-
'app',
150-
'routes',
151-
'config',
152-
'database',
153-
// Make sure "public" is listed in your config [tl! highlight:1]
154-
'public',
155-
],
156-
]
192+
# Terminal 2
193+
php artisan native:watch android
157194
```
158195

159-
### Order matters
160-
161-
Depending on which order you run these commands, you may find that hot reloading doesn't work immediately. It's often
162-
best to get the commands running, get your app open, and then make a request to a new screen to allow your app to pick
163-
up the `hot` file's presence and connect to the HMR server.
196+
This way you can see your changes reflected in real-time on both platforms **at the same time**. Wild.
164197

198+
</aside>
165199

166-
<aside>
200+
This is useful during development for quickly testing changes without re-compiling your entire app. When you make
201+
changes to any files in your Laravel app, the web view will be reloaded and your changes should show almost immediately.
167202

203+
Vite HMR is perfect for apps that use SPA frameworks like Vue or React to build the UI. It even works on real devices,
204+
not just simulators! As long as the device is on the same network as the development machine.
168205

206+
**Don't forget to add `public/ios-hot` and `public/android-hot` to your `.gitignore` file!**
169207

170-
#### Skip the prompts
208+
<aside>
171209

172-
If you are tired of prompts, you can run most commands - like `native:run` - with arguments and options that allow you
173-
to skip various prompts. Use the `--help` flag on a command to find out what values you can pass directly to it:
210+
#### Real iOS Devices Support
174211

175-
```shell
176-
php artisan native:run --help
177-
```
212+
Full hot reloading support works best on simulators. Full hot reloading support for non-JS changes on real iOS devices
213+
is not yet available.
178214

179215
</aside>
180216

0 commit comments

Comments
 (0)