> ## Documentation Index
> Fetch the complete documentation index at: https://docs.getlaunch.it/llms.txt
> Use this file to discover all available pages before exploring further.

# Helper Functions

> Essential utility functions for URL handling, logging, and purchase management

## URL Utilities

<ResponseField name="getUrl" type="function">
  Get the full URL path based on your site URL and locale settings.

  <Expandable title="Parameters">
    <ResponseField name="path" type="string" default="">
      The path to append to the base URL
    </ResponseField>

    <ResponseField name="locale" type="string" default="">
      The locale to use for i18n routing. Will default to the user's locale if not provided and language routing is enabled.
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="string">
      The complete URL path including the site URL and locale if i18n routing is enabled
    </ResponseField>
  </Expandable>
</ResponseField>

## Request Utilities

<ResponseField name="getIP" type="function">
  Extract the client IP address from incoming requests, supporting both Cloudflare and Vercel deployments.

  <Expandable title="Parameters">
    <ResponseField name="request" type="NextRequest" required>
      The incoming Next.js request object
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="string">
      The client IP address
    </ResponseField>
  </Expandable>
</ResponseField>

## Logging

<ResponseField name="createLog" type="function">
  Create a log entry in the database for tracking and monitoring.

  <Expandable title="Parameters">
    <ResponseField name="source" type="LogSource" required>
      The source of the log entry
    </ResponseField>

    <ResponseField name="message" type="string" required>
      The log message
    </ResponseField>

    <ResponseField name="options" type="LogOptions" default="{}">
      Additional logging options
    </ResponseField>
  </Expandable>
</ResponseField>

## Purchase Management

### Purchase Utilities

<ResponseField name="findConfiguredPurchase" type="function">
  Get the configuration object for a purchase.

  <Expandable title="Parameters">
    <ResponseField name="purchase" type="Purchase | null" required>
      The purchase database object
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="OneTimePurchaseProduct">
      The configuration object for the purchase
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="getPurchaseName" type="function">
  Get the configured name for a purchase.

  <Expandable title="Parameters">
    <ResponseField name="purchase" type="Purchase | null" required>
      The purchase database object
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="string">
      The configured name of the purchase
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="hasActivePurchase" type="function">
  Check if a user has an active purchase for a specific product.

  <Expandable title="Parameters">
    <ResponseField name="purchases" type="Purchase[] | null" required>
      Array of user's purchases
    </ResponseField>

    <ResponseField name="configPurchase" type="OneTimePurchaseProduct" required>
      The product configuration to check against
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="Purchase | undefined">
      The active purchase object if found, undefined otherwise
    </ResponseField>
  </Expandable>
</ResponseField>

### Subscription Utilities

<ResponseField name="findConfiguredPlan" type="function">
  Get the configuration object for a subscription plan.

  <Expandable title="Parameters">
    <ResponseField name="subscription" type="Subscription | null" required>
      The subscription database object
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="SubscriptionProduct">
      The configuration object for the subscription plan
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="getPlanName" type="function">
  Get the configured name for a subscription plan.

  <Expandable title="Parameters">
    <ResponseField name="subscription" type="Subscription | null" required>
      The subscription database object
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="string">
      The configured name of the subscription plan
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="hasActivePlan" type="function">
  Check if a user has an active subscription for a specific plan.

  <Expandable title="Parameters">
    <ResponseField name="subscription" type="Subscription | null" required>
      The subscription database object
    </ResponseField>

    <ResponseField name="configPlan" type="SubscriptionProduct" required>
      The plan configuration to check against
    </ResponseField>
  </Expandable>

  <Expandable title="Returns">
    <ResponseField type="boolean">
      True if the user has an active subscription for the specified plan
    </ResponseField>
  </Expandable>
</ResponseField>
