MediaSFU ReactJS
    Preparing search index...

    Variable PreJoinPageConst

    PreJoinPage: React.FC<PreJoinPageOptions> = ...

    PreJoinPage - A comprehensive pre-meeting entry page with dual create/join functionality.

    This component provides a complete pre-meeting interface allowing users to either create new meeting rooms or join existing ones. It handles form validation, API integration, socket connections, and supports both UI and headless (no-UI) modes for flexible integration.

    Key Features:

    • Dual Mode Operation: Seamless toggle between room creation and joining interfaces
    • Room Creation: Configure event type (chat/broadcast/webinar/conference), duration, capacity
    • Room Joining: Enter event ID, username, and optional security code
    • API Integration: Connects to MediaSFU or local server for room management
    • Socket Management: Establishes WebSocket connections for real-time communication
    • Form Validation: Comprehensive validation with user-friendly error messages
    • Headless Mode: Support for no-UI operation with programmatic configuration
    • Credential Management: Handles API authentication and token management
    • Loading States: Integrated loading modal during connection/validation
    • Custom Styling: 20+ HTML attribute props for complete visual customization
    • Render Hooks: Six custom render functions for logo, forms, toggle, errors, and container
    • Media Preferences: Configure video, audio, and audio output settings before joining
    • Local/Remote Servers: Flexible connection to MediaSFU cloud or local instances
    • Scheduled Events: Support for scheduled meeting times with date/time pickers
    • Security Features: Optional secure codes and waiting room functionality
    • Recording Configuration: Pre-configure recording parameters and event room settings
    • Responsive Design: Mobile-friendly interface with touch-optimized controls

    Configuration options for PreJoinPage

    Core parameters for room operations and state management

    Function to display alert messages to users

    Function to toggle loading modal visibility

    Function to establish MediaSFU socket connection

    Function to establish local server socket connection

    Function to update the active socket instance

    Function to update the local socket instance

    Function to mark connection as validated

    Function to store API username

    Function to store API authentication token

    Function to store meeting link

    Function to store room name

    Function to store member name

    Logo image source URL for branding

    API credentials (apiUserName and apiKey)

    Flag to enable UI mode (true) or headless mode (false)

    Configuration for headless mode operation

    URL for local server connection (empty string for MediaSFU cloud)

    Flag to enable MediaSFU cloud connection

    Function to create room on MediaSFU

    Function to join room on MediaSFU

    HTML attributes for main container

    HTML attributes for logo container

    HTML attributes for logo image

    HTML attributes for input fields container

    HTML attributes for "OR" separator container

    HTML attributes for "OR" text element

    HTML attributes for mode toggle container

    HTML attributes for toggle button

    HTML attributes for create room button

    HTML attributes for join room button

    HTML attributes for create mode name input

    HTML attributes for duration input

    HTML attributes for capacity input

    HTML attributes for event type select

    HTML attributes for join mode name input

    HTML attributes for event ID input

    HTML attributes for error message container

    Custom render function for main container

    Custom render function for logo

    Custom render function for create room form

    Custom render function for join room form

    Custom render function for mode toggle

    Custom render function for error display

    Custom render function for entire content area

    The rendered pre-join page component

    // Basic usage with UI mode

    import React from 'react';
    import { PreJoinPage } from 'mediasfu-reactjs';

    const BasicPreJoin = () => {
    const handleAlert = (message: string) => {
    alert(message);
    };

    return (
    <PreJoinPage
    credentials={{
    apiUserName: 'user123',
    apiKey: 'your-api-key'
    }}
    returnUI={true}
    parameters={{
    showAlert: handleAlert,
    updateIsLoadingModalVisible: (visible) => console.log('Loading:', visible),
    connectSocket: async ({ socket, apiUserName, apiToken }) => {
    // Socket connection logic
    },
    updateSocket: (socket) => console.log('Socket updated'),
    updateValidated: () => console.log('Validated'),
    updateApiUserName: (name) => console.log('API User:', name),
    updateApiToken: (token) => console.log('Token set'),
    updateLink: (link) => console.log('Link:', link),
    updateRoomName: (room) => console.log('Room:', room),
    updateMember: (member) => console.log('Member:', member),
    imgSrc: 'https://example.com/logo.png'
    }}
    connectMediaSFU={true}
    />
    );
    };

    // Custom styled with branding and validation

    import React, { useState } from 'react';
    import { PreJoinPage } from 'mediasfu-reactjs';

    const BrandedPreJoin = () => {
    const [isLoading, setIsLoading] = useState(false);

    return (
    <PreJoinPage
    credentials={{
    apiUserName: 'company_user',
    apiKey: 'company_api_key'
    }}
    returnUI={true}
    parameters={{
    showAlert: (message) => {
    console.log('Alert:', message);
    },
    updateIsLoadingModalVisible: setIsLoading,
    connectSocket: async (options) => {},
    updateSocket: (socket) => {},
    updateValidated: () => {},
    updateApiUserName: (name) => {},
    updateApiToken: (token) => {},
    updateLink: (link) => {},
    updateRoomName: (room) => {},
    updateMember: (member) => {},
    imgSrc: 'https://company.com/logo.svg'
    }}
    containerProps={{
    style: {
    background: 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
    minHeight: '100vh',
    fontFamily: "'Inter', sans-serif"
    }
    }}
    createButtonProps={{
    style: {
    backgroundColor: '#10b981',
    padding: '14px 28px',
    borderRadius: '8px',
    fontSize: '16px',
    fontWeight: '600',
    border: 'none',
    cursor: 'pointer',
    transition: 'all 0.3s'
    }
    }}
    joinButtonProps={{
    style: {
    backgroundColor: '#3b82f6',
    padding: '14px 28px',
    borderRadius: '8px',
    fontSize: '16px',
    fontWeight: '600',
    border: 'none',
    cursor: 'pointer'
    }
    }}
    renderLogo={({ imgSrc }) => (
    <div style={{ textAlign: 'center', marginBottom: '40px' }}>
    <img src={imgSrc} alt="Company Logo" style={{ width: '200px' }} />
    <h1 style={{ color: 'white', marginTop: '20px' }}>Welcome to Our Platform</h1>
    </div>
    )}
    />
    );
    };

    // Analytics tracking with event monitoring

    import React, { useEffect } from 'react';
    import { PreJoinPage } from 'mediasfu-reactjs';

    const AnalyticsPreJoin = () => {
    useEffect(() => {
    analytics.page('Pre-Join Page Viewed');
    }, []);

    return (
    <PreJoinPage
    credentials={{
    apiUserName: 'analytics_user',
    apiKey: 'analytics_key'
    }}
    returnUI={true}
    parameters={{
    showAlert: (message) => {
    analytics.track('Alert Shown', { message });
    alert(message);
    },
    updateIsLoadingModalVisible: (visible) => {
    analytics.track('Loading State Changed', { visible });
    },
    connectSocket: async (options) => {
    analytics.track('Socket Connection Initiated', {
    apiUserName: options.apiUserName
    });
    },
    updateValidated: () => {
    analytics.track('Connection Validated');
    },
    updateRoomName: (room) => {
    analytics.track('Room Entered', { roomName: room });
    },
    updateSocket: (socket) => {},
    updateApiUserName: (name) => {},
    updateApiToken: (token) => {},
    updateLink: (link) => {},
    updateMember: (member) => {}
    }}
    renderToggle={({ defaultToggle, isCreateMode, toggle }) => (
    <div onClick={() => {
    analytics.track('Mode Toggled', {
    from: isCreateMode ? 'create' : 'join',
    to: isCreateMode ? 'join' : 'create'
    });
    toggle();
    }}>
    {defaultToggle}
    </div>
    )}
    createMediaSFURoom={async (options) => {
    analytics.track('Room Creation Attempted', {
    eventType: options.eventType,
    duration: options.duration,
    capacity: options.capacity
    });
    const result = await createRoomOnMediaSFU(options);
    analytics.track('Room Created Successfully', {
    eventType: options.eventType
    });
    return result;
    }}
    joinMediaSFURoom={async (options) => {
    analytics.track('Room Join Attempted', {
    eventID: options.eventID
    });
    const result = await joinRoomOnMediaSFU(options);
    analytics.track('Room Joined Successfully');
    return result;
    }}
    />
    );
    };

    // Integration with MediasfuGeneric using uiOverrides

    import React, { useState } from 'react';
    import { MediasfuGeneric, PreJoinPage } from 'mediasfu-reactjs';

    const CustomPreJoin = (props) => (
    <PreJoinPage
    {...props}
    renderContent={({ defaultContent, isCreateMode, error }) => (
    <div className="custom-prejoin-wrapper">
    <div className="welcome-banner">
    <h2>🎥 {isCreateMode ? 'Start Your Meeting' : 'Join the Meeting'}</h2>
    <p>Connect with your team in seconds</p>
    </div>
    {error && (
    <div className="error-banner" style={{
    backgroundColor: '#fee',
    color: '#c00',
    padding: '12px',
    borderRadius: '6px',
    marginBottom: '20px'
    }}>
    ⚠️ {error}
    </div>
    )}
    {defaultContent}
    <div className="help-section">
    <a href="/help">Need help?</a>
    <span> | </span>
    <a href="/privacy">Privacy Policy</a>
    </div>
    </div>
    )}
    renderCreateForm={({ defaultForm }) => (
    <div className="enhanced-create-form">
    <div className="form-header">
    <h3>Create New Room</h3>
    <p>Set up your meeting parameters</p>
    </div>
    {defaultForm}
    <div className="form-footer">
    <small>🔒 Your meeting will be secure and encrypted</small>
    </div>
    </div>
    )}
    />
    );

    const App = () => {
    const [credentials] = useState({
    apiUserName: 'user123',
    apiKey: 'your-api-key'
    });

    return (
    <MediasfuGeneric
    credentials={credentials}
    uiOverrides={{
    PreJoinPage: CustomPreJoin
    }}
    />
    );
    };