Start URL

The start_url parameter defines the URL that should be loaded when a user launches your PWA from their home screen or app launcher. This is typically the main entry point of your application.

Basic Usage

The simplest way to define a start URL is to provide a Symfony route name:

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
        start_url: "app_homepage"

You can also use a simple path string:

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
        start_url: "/"

Advanced Configuration

For more complex scenarios, you can use the full URL object configuration that allows you to specify route parameters and path types:

/config/packages/pwa.yaml
pwa:
    manifest:
        enabled: true
        start_url:
            path: "app_dashboard"
            params:
                utm_source: "pwa"
                utm_medium: "homescreen"
            path_type_reference: 1

Path Parameter

The path parameter can be:

  • A Symfony route name (e.g., "app_homepage")

  • An absolute URL (e.g., "https://example.com/app")

  • A relative path (e.g., "/app")

  • A network path (e.g., "//example.com/app")

Params Parameter

The params parameter allows you to pass route parameters or query string parameters:

/config/packages/pwa.yaml
pwa:
    manifest:
        start_url:
            path: "app_article"
            params:
                id: 123
                slug: "welcome"

This is particularly useful for:

  • Tracking PWA installations with analytics parameters

  • Pre-loading specific content when the app launches

  • Passing initial state to your application

Path Type Reference

The path_type_reference option controls how the URL is generated:

  • 0: Absolute URL - Generates a full URL with protocol and domain (e.g., https://app.com/foo/bar)

  • 1: Absolute Path (default) - Generates a path starting from root (e.g., /foo/bar)

  • 2: Relative Path - Generates a relative path (e.g., ../bar)

  • 3: Network Path - Generates a protocol-relative URL (e.g., //app.com/foo/bar)

/config/packages/pwa.yaml
pwa:
    manifest:
        start_url:
            path: "app_homepage"
            path_type_reference: 0  # Absolute URL

Best Practices

  1. Keep it within scope: The start_url must be within the application's scope.

  2. Use route names: Prefer Symfony route names over hardcoded paths for better maintainability.

  3. Analytics tracking: Add tracking parameters to distinguish PWA launches from regular visits:

/config/packages/pwa.yaml
pwa:
    manifest:
        start_url:
            path: "app_homepage"
            params:
                utm_source: "pwa"
                utm_medium: "homescreen"
  1. Consistency: The start_url should always resolve to the same logical page, even if the underlying route changes.

Examples

Simple Route

/config/packages/pwa.yaml
pwa:
    manifest:
        start_url: "app_dashboard"

Route with Parameters

/config/packages/pwa.yaml
pwa:
    manifest:
        start_url:
            path: "app_user_profile"
            params:
                username: "current"

With Tracking Parameters

/config/packages/pwa.yaml
pwa:
    manifest:
        start_url:
            path: "app_homepage"
            params:
                utm_source: "pwa"
                utm_campaign: "install"
                ref: "homescreen"

The start_url is not translatable since version 1.3.0. If you need localized start URLs, use the {locale} placeholder in the manifest public URL configuration. See Localisation & Translations for more details.

Last updated

Was this helpful?