You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance the delivery of your media assets by integrating svelte-cloudinary with a [private CDN and/or custom domain](https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_custom_delivery_hostnames_cnames).
6
+
7
+
:::note
8
+
**Private CDN** and **Custom Domain** features are available exclusively on [Cloudinary's Advanced plan](https://cloudinary.com/pricing).
9
+
:::
10
+
11
+
## Step-by-Step Configuration
12
+
13
+
### 1. Install Dependencies
14
+
15
+
Ensure you have **svelte-cloudinary** installed in your project:
16
+
17
+
```bash
18
+
npm install svelte-cloudinary
19
+
```
20
+
21
+
### 2. Set Up Environment Variables
22
+
23
+
Create a `.env` file in your project root (if it doesn't exist already) and add the following variables:
Replace your_cloud_name with your actual Cloudinary cloud name and your-custom-domain.com with your custom domain. Read more about [configuring svelte-cloudinary here](https://svelte.cloudinary.dev/config).
31
+
32
+
:::caution
33
+
Never commit your `.env` file to version control. Add it to your `.gitignore` file to keep sensitive information secure.
34
+
:::
35
+
36
+
## Example Usage
37
+
38
+
With the configuration in place, use the `<CldImage />` component to serve images through your private CDN and custom domain:
39
+
40
+
```svelte
41
+
<script>
42
+
import { CldImage } from 'svelte-cloudinary';
43
+
</script>
44
+
45
+
<CldImage
46
+
src="<Your Public ID>"
47
+
alt="Sample Image"
48
+
width="800"
49
+
height="600"
50
+
/>
51
+
```
52
+
53
+
This setup ensures that the image URL follows your custom domain structure:
Learn more about setting up CNAME records on the [Cloudinary docs](https://cloudinary.com/documentation/advanced_url_delivery_options#private_cdns_and_custom_delivery_hostnames_cnames).
0 commit comments