Skip to content

Embed in a Web Page

This guide covers embedding panes beyond the basics. If you have not embedded a pane before, start with Embed Your First Pane.

Multiple services on one page

Add a service request and target div for each service you want to display. All requests are sent in a single batch API call.

multi-service.html
<!-- Access key (once per page) -->
<script>
    window.lpEmbed = {
        accessKey: 'lp_ak_YOUR_ACCESS_KEY_HERE'
    };
</script>

<!-- EC2 instances -->
<h2>EC2 Instances</h2>
<div data-lp-service="ec2"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="name,instance_id,instance_type,state"></div>

<!-- S3 buckets -->
<h2>S3 Buckets</h2>
<div data-lp-service="s3"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="bucket_name,creation_date,region"></div>

<!-- Lambda functions -->
<h2>Lambda Functions</h2>
<div data-lp-service="lambda_functions"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="name,runtime,memory,timeout,last_modified"></div>

<!-- SDK scripts (once, at end of page) -->
<script src="https://lightpane.io/embed/lp.js"></script>

The SDK batches all requests into a single API call. Each response is matched to its target div by the data-lp-service attribute.

Choose which columns to display

The attributes array controls which columns appear in the rendered table. Omit attributes entirely to show all available columns for that service.

// Show only name and state
// Show all available columns

See the Service Catalogue for the full list of available attributes per service.

Multiple regions

Add separate requests for each region. Use different target divs.

<h2>EU West 2</h2>
<div data-lp-service="ec2"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="name,instance_id,instance_type,state"></div>

<h2>US East 1</h2>
<div data-lp-service="ec2"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="us-east-1"
     data-lp-attributes="name,instance_id,instance_type,state"></div>

Multiple cloud providers

Mix AWS and GCP services on the same page. The SDK handles routing each request to the correct provider.

<h2>AWS EC2 Instances</h2>
<div data-lp-service="ec2"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="name,instance_id,instance_type,state"></div>

<h2>GCP Compute Instances</h2>
<div data-lp-service="compute_instances"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="europe-west2"
     data-lp-attributes="name,machine_type,status,zone"></div>

Batch request limits

If your access key has a max_batch_size constraint, the SDK splits requests into batches automatically. A key with max_batch_size: 5 and 12 service requests will make 3 API calls (5 + 5 + 2).

For pages with many services, increase the max_batch_size on your access key or remove the constraint entirely.

Page layout with Bootstrap

Pane components do not require Bootstrap, but you can use Bootstrap's grid to arrange panes side by side.

<link rel="stylesheet"
      href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css">

<div class="container mt-4">
    <div class="row">
        <div class="col-md-6">
            <h3>EC2 Instances</h3>
            <div data-lp-service="ec2"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="name,instance_id,instance_type,state"></div>
        </div>
        <div class="col-md-6">
            <h3>S3 Buckets</h3>
            <div data-lp-service="s3"
     data-lp-account="YOUR_ACCOUNT_HANDLE"
     data-lp-region="eu-west-2"
     data-lp-attributes="bucket_name,creation_date,region"></div>
        </div>
    </div>
</div>

Refreshing data

Panes load data once when the page loads. To re-render without a full page reload, call the loader's render entry point:

// Refresh all panes on the page
if (typeof window.lpEmbedRun === 'function') {
    window.lpEmbedRun();
}

You can wire this to a button:

<button onclick="window.lpEmbedRun()">Refresh</button>

This re-renders; it does not force a fetch

Each pane has a freshness window set by your plan — see Pricing. Within that window the loader serves the data it already has, so calling lpEmbedRun() again immediately will redraw the same figures rather than query your cloud. That is deliberate: every fetch is a charged API call against your own account.

CORS and access key setup

For embedded pages, your access key needs:

  • allowed_origins set to the domain(s) where the page is hosted
  • Type set to embed

If you are developing locally, add your local URL (e.g. http://localhost:3000) to allowed_origins during development. Remove it before deploying.

Testing locally

Serve the page from a local web server rather than opening the HTML file directly. The file:// protocol does not send Origin headers, which causes constraint validation to fail.

python3 -m http.server 8080