@grabjs/superapp-sdk
    Preparing search index...

    Class PlatformModule

    SDK module for controlling platform navigation via JSBridge.

    Provides methods to interact with the native platform navigation stack, such as triggering the back action. This code must run on the Grab SuperApp's WebView to function correctly.

    ES Module:

    import { PlatformModule } from '@grabjs/superapp-sdk';
    const platform = new PlatformModule();

    CDN (UMD):

    <script src="https://cdn.jsdelivr.net/npm/@grabjs/superapp-sdk@x.y.z/dist/index.js"></script>
    <script>
    const platform = new SuperAppSDK.PlatformModule();
    </script>

    Hierarchy (View Summary)

    Index

    Constructors

    Methods

    Constructors

    Methods

    • Triggers the native platform back navigation. This navigates back in the native navigation stack.

      Returns Promise<BackResponse>

      This method can return the following status_code values:

      • 204 (No Content): Back navigation triggered successfully.
      • 500 (Internal Server Error): An unexpected error occurred.
      • 501 (Not Implemented): Requires Grab app environment.
      import { PlatformModule, isSuccess, isError } from '@grabjs/superapp-sdk';

      // Initialize the platform module
      const platform = new PlatformModule();

      // Trigger back navigation
      const response = await platform.back();

      // Handle the response
      if (isSuccess(response)) {
      console.log('Back navigation triggered');
      } else if (isError(response)) {
      console.error(`Error ${response.status_code}: ${response.error}`);
      } else {
      console.error('Unhandled response');
      }