πŸš€ DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

@botanicastudios/preview-app-bridge-remix

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@botanicastudios/preview-app-bridge-remix

A comprehensive React package for Shopify App Bridge preview functionality. This package provides mock implementations and preview components that allow developers to build and test Shopify apps without requiring a full Shopify environment.

latest
npmnpm
Version
0.0.3
Version published
Maintainers
1
Created
Source

Preview App Bridge React

A comprehensive React package for Shopify App Bridge preview functionality. This package provides mock implementations and preview components that allow developers to build and test Shopify apps without requiring a full Shopify environment.

Features

Components

  • Modal: Preview modal component with App Bridge-like functionality
  • TitleBar: Preview title bar with actions and breadcrumbs
  • PreviewTitleBar: Enhanced title bar for preview mode
  • NavMenu: Navigation menu component
  • PreviewNavMenu: Enhanced nav menu for preview mode
  • SaveBar: Save bar component for form workflows
  • ResourcePicker: Resource picker component with mock data
  • PortalTitleBar: Portal-based title bar component

Hooks

  • useAppBridge: Hook for accessing App Bridge functionality
  • useAppBridgeContext: Hook for accessing App Bridge context

Context

  • AppBridgeProvider: Provider component for App Bridge context
  • AppBridgeContext: React context for App Bridge state

APIs

  • toast: Toast notification API
  • loading: Loading state management API
  • resourcePicker: Resource picker API with mock data
  • picker: Generic picker API
  • reviews: Review request API

Services

  • TokenGenerator: JWT token generation and caching service
  • RequestInterceptor: Request interception service
  • GraphQLClient: GraphQL client with mock capabilities

Server Utilities

  • JWTSigner: Server-side JWT signing utilities

Installation

This package is designed to be used as a local module within your Shopify app project.

Usage

Basic Setup

import React from 'react';
import { AppBridgeProvider } from 'preview-app-bridge-react';

function App() {
  return (
    <AppBridgeProvider>
      {/* Your app components */}
    </AppBridgeProvider>
  );
}

Using the Hook

import React from 'react';
import { useAppBridge } from 'preview-app-bridge-react';
import { Button } from '@shopify/polaris';

function MyComponent() {
  const shopify = useAppBridge();
  
  const handleSelectProducts = async () => {
    try {
      const products = await shopify.resourcePicker({
        type: 'product',
        multiple: true,
      });
      
      shopify.toast.show(`Selected ${products.length} products`);
    } catch (error) {
      shopify.toast.error('Failed to select products');
    }
  };
  
  return (
    <Button onClick={handleSelectProducts}>
      Select Products
    </Button>
  );
}

Using Components

import React, { useState } from 'react';
import { Modal, TitleBar } from 'preview-app-bridge-react';

function MyPage() {
  const [modalOpen, setModalOpen] = useState(false);
  
  return (
    <>
      <TitleBar
        title="My Page"
        primaryAction={{
          content: 'Open Modal',
          onAction: () => setModalOpen(true),
        }}
      />
      
      <Modal
        open={modalOpen}
        onClose={() => setModalOpen(false)}
        title="Example Modal"
        primaryAction={{
          content: 'Save',
          onAction: () => {
            // Handle save
            setModalOpen(false);
          },
        }}
      >
        <p>Modal content goes here</p>
      </Modal>
    </>
  );
}

Development Mode

The package includes auto-initialization functionality that can be enabled in preview mode:

import { initializePreviewAppBridge } from 'preview-app-bridge-react';

// Initialize preview mode (typically in your app's entry point)
if (process.env.NODE_ENV === 'development') {
  initializePreviewAppBridge();
}

File Structure

preview-app-bridge-react/
β”œβ”€β”€ index.ts                      # Main package exports
β”œβ”€β”€ package.json                  # Package configuration
β”œβ”€β”€ components/                   # React components
β”‚   β”œβ”€β”€ Modal.tsx
β”‚   β”œβ”€β”€ TitleBar.tsx
β”‚   β”œβ”€β”€ NavMenu.tsx
β”‚   └── ...
β”œβ”€β”€ hooks/                        # React hooks
β”‚   β”œβ”€β”€ useAppBridge.tsx
β”‚   └── index.ts
β”œβ”€β”€ context/                      # React context
β”‚   β”œβ”€β”€ AppBridgeContext.tsx
β”‚   └── index.ts
β”œβ”€β”€ apis/                         # Mock APIs
β”‚   β”œβ”€β”€ toast.ts
β”‚   β”œβ”€β”€ loading.ts
β”‚   β”œβ”€β”€ resource-picker.ts
β”‚   └── ...
β”œβ”€β”€ services/                     # Utility services
β”‚   β”œβ”€β”€ token-generator.ts
β”‚   β”œβ”€β”€ request-interceptor.ts
β”‚   └── ...
β”œβ”€β”€ types/                        # TypeScript type definitions
β”‚   └── index.ts
β”œβ”€β”€ server/                       # Server-side utilities
β”‚   └── jwt-signer.ts
β”œβ”€β”€ auto-init.ts                  # Auto-initialization
β”œβ”€β”€ examples.ts                   # Usage examples
└── comprehensive-usage-example.tsx

TypeScript Support

This package is built with TypeScript and provides comprehensive type definitions for all components, hooks, and APIs.

License

MIT

Keywords

shopify

FAQs

Package last updated on 16 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts