# Load Content

Positron gives you full control over what web content is loaded into your native window viewports. You can load local frontend source files packaged with your application or navigate to remote web addresses.

### Loading Local HTML Files

To render user interfaces bundled directly inside your application assets, use the `loadFile` method. This handles resource resolution correctly across your local filesystem paths.

{% code lineNumbers="true" %}

```javascript
const path = require('path');

// Resolve the absolute file path safely using Node's path module
const entryPoint = path.join(__dirname, 'public', 'index.html');

mainWindow.on('ready', async () => {
  // Instructs WebKit / WebView2 to load the local resource
  mainWindow.loadFile(entryPoint);
});
```

{% endcode %}

#### Best Practice: Bundle Path Isolation

Always combine `__dirname` with Node’s native `path.join()` or `path.resolve()`. Passing hardcoded or raw relative path strings like `./index.html` directly into `loadFile` will fail when your application is compiled and packaged into a production bundle (`.app` or `.exe`).

### Loading Remote URLs

To load live web applications, dashboards, or external websites into your container, pass a fully qualified URL to the `loadURL` method.

{% code lineNumbers="true" %}

```javascript
mainWindow.on('ready', async () => {
  // Load an external website securely via HTTPS
  mainWindow.loadURL("https://www.google.com");
});
```

{% endcode %}

#### Security Advisory for Remote URLs

When loading third-party websites or external services via `loadURL`:

* Ensure the target endpoint uses **HTTPS** to maintain encryption integrity between the user and the server.
* Be conscious of exposing raw native IPC privileges (`window.ipc.send`) to untrusted domains. Use User Scripts or preloads to safely isolate communication channels if your window exposes native system capabilities.

### Get The Current URL

{% code lineNumbers="true" %}

```javascript
mainWindow.on('ready', async () => {
  const url = await mainWindow.getURL();
});
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://positronjs.gitbook.io/v1/commands/load-content.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
