---
name: "getAssetHostname"
mode: "kit"
versionRequirements:
  - { name: "@ray-js/ray", version: "0.5.10" }
---

## getAssetHostname

> [VERSION] @ray-js/ray >= 0.5.10

### Description

Automatically obtains the static resource URL based on the App environment of the current panel

### Parameters

None


### Examples

#### Basic usage

```tsx
import React, { useState } from 'react';
import { View, Button, Text, getAssetHostname } from '@ray-js/ray';

export default function Demo() {
  const [hostname, setHostname] = useState('');

  const handleGetHostname = async () => {
    try {
      const result = await getAssetHostname();
      setHostname(result);
      console.log('Static asset hostname:', result);
    } catch (err) {
      console.error('Failed to get:', err);
    }
  };

  return (
    <View style={{ padding: 20 }}>
      <Button onClick={handleGetHostname}>Get static asset hostname</Button>
      {hostname && <Text style={{ marginTop: 10 }}>{hostname}</Text>}
    </View>
  );
}
```
