React with Vite, self-hosted Next.js, and Django can all move static asset delivery to a content delivery network, but they do not expose those assets in the same way. A Vite application writes a static production build. A self-hosted Next.js application combines a running server with versioned framework assets. Django collects static files into a separate deployment directory while dynamic requests continue through WSGI or ASGI.
This guide explains how to choose the correct CDNsun integration path for each model. The shared objective is to serve suitable static assets from the CDN Service Domain while keeping dynamic HTML, rendering, APIs, and authentication at the origin.
Three application models, one CDN objective
A CDN places cacheable files closer to visitors and takes repeat asset requests away from the application origin. That principle applies to all three stacks. The decisive question is where production assets are created, how the application generates their URLs, and which origin path exposes the resulting files to the CDN.
Vite embeds a configured base URL during a production build. Next.js uses assetPrefix to direct framework-managed assets under /_next/static/ to another host. Django resolves static URLs through its staticfiles system and can add hashed filenames through manifest storage. Each mechanism changes asset references at a different stage, so settings cannot simply be copied between platforms.
The boundary between static and dynamic delivery should remain explicit. The CDN handles files such as generated JavaScript, CSS, images, and other build output covered by the chosen integration. The application origin remains responsible for server rendering, API responses, sessions, authentication, and other dynamic behavior.
Common prerequisites
Before changing framework settings, create one CDNsun Static Pull service and note its CDN Service Domain. Configure the service to pull from the hostname and origin path that actually expose the production assets. The CDN hostname should be available over HTTPS before it is inserted into production configuration.
Keep origin files publicly reachable at the URLs the CDN will request. Test a representative JavaScript, CSS, or image URL directly at the origin, then request the equivalent path through the CDN Service Domain. This separates origin deployment problems from CDN configuration problems.
Verify a production build. Development servers may generate different paths, serve files from memory, or bypass deployed asset settings. The browser network panel should show intended assets loading from the CDN hostname while dynamic requests continue to reach the origin.
CDN integration chooser
| Application model | Primary setting | CDN asset scope | Origin deployment requirement | Tested versions |
|---|---|---|---|---|
| React with Vite static frontend | Production-only Vite base |
Generated JavaScript, CSS, and imported build assets | Build with npm run build and deploy the complete dist/ directory unchanged |
React 19.2.8, Vite 8.2.2 |
| Self-hosted Next.js runtime | Production assetPrefix |
Versioned framework assets under /_next/static/ |
Deploy the matching standalone runtime and .next/static/ output together |
Next.js 16.3.4, React 19.2.8 |
| Django server-rendered application | STATIC_URL, STATIC_ROOT, and ManifestStaticFilesStorage |
Collected and manifest-versioned static files | Run collectstatic and expose the exact collected directory through the origin web server |
Django 5.2.17 |
The table identifies the control point for each stack. The sections below explain what must remain synchronized after configuration.
React with Vite: prefix the static production build
Best for: React frontends that use Vite to produce a static deployment bundle.
In a React 19.2.8 and Vite 8.2.2 application, a production-only Vite base can point generated asset URLs at the CDN Service Domain. Vite then applies that base when it writes references for generated JavaScript, CSS, and imported build assets. Keeping the setting production-only prevents the local development server from depending on the CDN.
After the change, run npm run build and deploy the complete dist/ directory without rearranging it. The HTML and assets were generated as one unit; moving selected files can break embedded paths. Confirm that production network requests use the CDN hostname.
The setting does not rewrite every URL that appears in application code. In particular, root-relative paths assembled as runtime strings, such as /images/example.png, can continue to resolve against the application origin. Import assets through the build pipeline or construct their CDN URLs intentionally. Because production JavaScript modules are fetched across origins, apply the documented CORS configuration.
The complete React with Vite CDN tutorial provides the exact build setting, origin layout, CORS values, and validation steps. Use it when the deployment artifact is a static dist/ directory.

Once Vite’s generated URLs and deployed directory agree, the CDN can retrieve the files the page references. Next.js adds a moving part because its static files belong to a specific server build.
Self-hosted Next.js: separate runtime delivery from build assets
Best for: self-hosted Next.js applications that keep the application runtime at the origin and deliver framework-generated production assets through the CDN.
For Next.js 16.3.4 with React 19.2.8, set a production assetPrefix so URLs for versioned files under /_next/static/ use the CDN Service Domain. The Next.js server still handles server-rendered pages, route handlers, APIs, authentication, and other dynamic requests. This path is specifically for self-hosted deployments; it does not describe a managed hosting platform’s deployment behavior.
A standalone deployment must preserve the relationship between its runtime and build. Deploy the matching standalone server output and .next/static/ directory together. Mixing builds can leave rendered pages referring to files the origin, and therefore the CDN, cannot find. Test the exact origin URL before changing the CDN service.
assetPrefix has a narrower purpose than a general URL prefix. It does not rewrite files referenced from public/, so those URLs need a separate asset strategy if they should use the CDN. It is also distinct from basePath: assetPrefix changes the host or prefix used for framework assets, while basePath mounts the application below a URL sub-path.
The complete self-hosted Next.js CDN tutorial covers the precise configuration, standalone layout, required CORS values, and verification steps. Choose it when the application controls its runtime and can publish the matching .next/static/ output.

Next.js splits responsibility between a live runtime and build-specific assets. Django also keeps a live server at the origin, but a collection step creates its static-file boundary.
Django: collect and expose manifest-versioned static files
Best for: server-rendered Django applications that publish a separate, web-server-served directory of collected static files.
In Django 5.2.17, STATIC_URL determines the URL prefix emitted by Django’s static template tag, while STATIC_ROOT identifies the deployment directory populated by collectstatic. ManifestStaticFilesStorage adds content hashes and records the mapping from logical asset names to versioned filenames. Templates that use Django’s static tag then resolve to the collected, versioned files at the CDN Service Domain.
STATIC_ROOT is build output, not a directory for source assets. Application and package static files remain in their source locations; collectstatic gathers them into STATIC_ROOT. In production, expose that exact collected directory through Nginx or another origin web server so the CDN can retrieve each file. Dynamic WSGI or ASGI requests remain on the application origin and should not be routed through the static-file path.
Templates and stylesheets should rely on Django’s static resolution rather than hard-coded /static/ URLs. Hard-coded paths bypass the manifest lookup and may continue to reference the origin or an unhashed filename. Re-run collectstatic as part of each asset deployment so the manifest and published files remain synchronized.
The complete Django CDN tutorial gives the settings, collectstatic workflow, Nginx mapping, and validation steps. Use it when Django’s staticfiles pipeline owns the final asset names and URLs.

Choose the path that matches asset ownership
Across all three frameworks, static assets are requested repeatedly, suit caching, and do not need the application runtime to regenerate them for every visitor. The CDN Service Domain provides a delivery layer for those files while application logic stays at the origin.
Asset ownership remains framework-specific. Vite owns a self-contained frontend build and writes its base URL during compilation. Self-hosted Next.js owns versioned files tied to a server build and addresses them through assetPrefix. Django owns a collected static tree resolved through STATIC_URL and, when enabled, its manifest. The correct integration follows that model instead of forcing every stack into one URL convention.
Start by identifying the production artifact. If it is Vite’s complete dist/ directory, follow the React path. If it is a running self-hosted Next.js server accompanied by its matching .next/static/ directory, follow the Next.js path. If it is Django’s collectstatic output exposed by a web server, follow the Django path. Then verify one file at the origin, the same file through the CDN, and finally the generated page in the browser.
A sound integration gives the CDN a stable, reachable asset origin and makes the framework emit matching URLs. Once those sides agree, releases stay understandable: build or collect the files, deploy the complete matching output, and confirm that assets load from the CDN while dynamic traffic stays with the application.
Choose your integration path
Choose the tutorial that matches how the application creates and publishes its static files:
- Use the React with Vite guide when Vite produces a static
dist/deployment. - Use the self-hosted Next.js guide when a running Next.js server publishes matching assets under
/_next/static/. - Use the Django guide when
collectstaticpublishes a separately served static directory.
Ready to put the matching path into practice? Start a free trial and configure the application with CDNsun.

