Skip to main content
The AutoUpdater class provides methods to check for, download, and install application updates. It integrates with various update providers including GitHub Releases, AWS S3, and DigitalOcean Spaces.

Available Methods

checkForUpdates()

Check if a new version of your application is available.
use Native\Desktop\Facades\AutoUpdater;

AutoUpdater::checkForUpdates();
This method triggers the update check process. The updater compares your current application version (defined in config/nativephp.php) with the latest available version from your configured update provider. You can listen for update events to respond to the check results:
use Native\Desktop\Events\Updates\UpdateAvailable;
use Native\Desktop\Events\Updates\NoUpdateAvailable;

Event::listen(UpdateAvailable::class, function ($event) {
    // A new update is available
    // Show notification to user
});

Event::listen(NoUpdateAvailable::class, function () {
    // App is up to date
});

downloadUpdate()

Download the available update without installing it.
use Native\Desktop\Facades\AutoUpdater;

AutoUpdater::downloadUpdate();
This method downloads the update in the background. You can listen for download progress events:
use Native\Desktop\Events\Updates\UpdateDownloadProgress;
use Native\Desktop\Events\Updates\UpdateDownloaded;

Event::listen(UpdateDownloadProgress::class, function ($event) {
    // $event->bytesPerSecond
    // $event->percent
    // $event->transferred
    // $event->total
});

Event::listen(UpdateDownloaded::class, function () {
    // Download complete, ready to install
});

quitAndInstall()

Quit the application and install the downloaded update.
use Native\Desktop\Facades\AutoUpdater;

AutoUpdater::quitAndInstall();
This method immediately closes your application and begins the update installation process. After installation, the application will restart automatically with the new version.
Make sure the update has been downloaded before calling this method. Otherwise, it will have no effect.

Configuration

The updater is configured in your config/nativephp.php file:
'updater' => [
    'enabled' => env('NATIVEPHP_UPDATER_ENABLED', true),
    'default' => env('NATIVEPHP_UPDATER_PROVIDER', 'spaces'),
    
    'providers' => [
        // Provider configurations
    ],
],

Updater Options

enabled
bool
default:"true"
Whether the updater is enabled. The updater only works in production builds.
default
string
default:"spaces"
The default update provider to use. Supported values: github, s3, spaces.

GitHub Provider

Use GitHub Releases to distribute your updates:
'github' => [
    'driver' => 'github',
    'repo' => env('GITHUB_REPO'),
    'owner' => env('GITHUB_OWNER'),
    'token' => env('GITHUB_TOKEN'),
    'vPrefixedTagName' => env('GITHUB_V_PREFIXED_TAG_NAME', true),
    'private' => env('GITHUB_PRIVATE', false),
    'autoupdate_token' => env('GITHUB_AUTOUPDATE_TOKEN'),
    'channel' => env('GITHUB_CHANNEL', 'latest'),
    'releaseType' => env('GITHUB_RELEASE_TYPE', 'draft'),
],
repo
string
required
Your GitHub repository name.
owner
string
required
The GitHub username or organization that owns the repository.
token
string
GitHub personal access token for accessing private repositories.
vPrefixedTagName
bool
default:"true"
Whether your release tags are prefixed with ‘v’ (e.g., v1.0.0).
private
bool
default:"false"
Whether the repository is private.
autoupdate_token
string
Read-only token used by the updater to access private repositories from installed apps.
channel
string
default:"latest"
The release channel to use (e.g., ‘latest’, ‘beta’).
releaseType
string
default:"draft"
The type of release to publish: ‘draft’ or ‘release’.

S3 Provider

Use AWS S3 or S3-compatible services (like Cloudflare R2):
's3' => [
    'driver' => 's3',
    'key' => env('AWS_ACCESS_KEY_ID'),
    'secret' => env('AWS_SECRET_ACCESS_KEY'),
    'region' => env('AWS_DEFAULT_REGION'),
    'bucket' => env('AWS_BUCKET'),
    'endpoint' => env('AWS_ENDPOINT'),
    'path' => env('NATIVEPHP_UPDATER_PATH', null),
    'public_url' => env('AWS_PUBLIC_URL'),
],
key
string
required
AWS access key ID.
secret
string
required
AWS secret access key.
region
string
required
AWS region (e.g., ‘us-east-1’).
bucket
string
required
S3 bucket name.
endpoint
string
Custom S3 endpoint URL (for S3-compatible services).
path
string
Optional path prefix within the bucket.
public_url
string
Optional public URL for serving updates (e.g., CDN or custom domain). When set, updates are downloaded from this URL instead of the S3 endpoint.

Spaces Provider

Use DigitalOcean Spaces:
'spaces' => [
    'driver' => 'spaces',
    'key' => env('DO_SPACES_KEY_ID'),
    'secret' => env('DO_SPACES_SECRET_ACCESS_KEY'),
    'name' => env('DO_SPACES_NAME'),
    'region' => env('DO_SPACES_REGION'),
    'path' => env('NATIVEPHP_UPDATER_PATH', null),
],
key
string
required
DigitalOcean Spaces access key.
secret
string
required
DigitalOcean Spaces secret key.
name
string
required
Spaces name.
region
string
required
Spaces region (e.g., ‘nyc3’).
path
string
Optional path prefix within the Space.

Complete Example

use Native\Desktop\Facades\AutoUpdater;
use Native\Desktop\Events\Updates\UpdateAvailable;
use Native\Desktop\Events\Updates\UpdateDownloaded;
use Illuminate\Support\Facades\Event;

// Check for updates on app startup
AutoUpdater::checkForUpdates();

// Listen for update available
Event::listen(UpdateAvailable::class, function ($event) {
    // Show notification to user
    Notification::make()
        ->title('Update Available')
        ->message('A new version is available. Would you like to download it?')
        ->show();
    
    // Start downloading
    AutoUpdater::downloadUpdate();
});

// Listen for download complete
Event::listen(UpdateDownloaded::class, function () {
    // Ask user if they want to install now
    Notification::make()
        ->title('Update Ready')
        ->message('Update downloaded. Click to install and restart.')
        ->show();
    
    // When user clicks, call:
    // AutoUpdater::quitAndInstall();
});

Build docs developers (and LLMs) love