Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk2 min

INITIAL_CONFIG in Angular: What It Is and How to Set the Initial Document and URL for SSR

INITIAL_CONFIG is the @angular/platform-server token that supplies a PlatformConfig, setting the initial document and URL for server-side rendering.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

INITIAL_CONFIG is the dependency-injection token Angular uses for the initial configuration of the server platform. It is exported from @angular/platform-server, is declared as InjectionToken<PlatformConfig>, and Angular’s API reference describes it as “The DI token for setting the initial config for the platform.” Its value controls two things: the starting document and the starting URL of a server-rendered application.

What the token holds: PlatformConfig

The value you provide for INITIAL_CONFIG is a PlatformConfig object. Both of its properties are optional.

As an Amazon Associate I earn from qualifying purchases.

Property Purpose If omitted
document The initial DOM used to bootstrap the server application. Angular creates a new DOM using Domino.
url The URL for the current application state, used to initialize the platform location (protocol, hostname and port included). Not stated in the API reference; do not assume a default, and supply it when your routing or location logic depends on it.

In the current platform-server source, the token is read while the server document is being constructed. When a document string is configured, the platform parses it and can resolve it against the configured URL. That is why the two fields are usually set together.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Setting the initial document and URL

Because the token is just a provider key, you supply it in the providers of the server platform. A typical low-level form looks like this:

import { platformServer, INITIAL_CONFIG } from '@angular/platform-server';

const platformRef = platformServer([
  {
    provide: INITIAL_CONFIG,
    useValue: {
      document: '<html><body><app-root></app-root></body></html>',
      url: 'https://example.com/products/42'
    }
  }
]);

Treat this as an illustration of the shape of the config, not a drop-in setup. Check the signatures against the Angular version you run, since server bootstrapping APIs have changed across releases.

  • Use document when you need to control the HTML the app is bootstrapped into, such as a prepared index template.
  • Use url when the server needs to know which route and origin it is rendering, so the platform location and anything built on it start in the right place.
  • Provide neither and Angular falls back to a Domino-created DOM.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Do you need to touch it in a modern SSR app?

Usually not directly. Angular’s current server-side rendering guidance frames SSR, prerendering and client rendering as hybrid-rendering choices and configures SSR through higher-level APIs such as provideServerRendering. INITIAL_CONFIG sits underneath that as a lower-level platform token. Reach for it when you are writing custom server bootstrapping, building test harnesses that render with a fixed document and URL, or debugging why the server saw a different document or location than you expected.

Older Angular Universal tutorials often show manual platform setup. Don’t assume those examples are current. Identify your Angular version and follow the setup documented for it.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Debugging checklist

  • Wrong route rendered on the server: check that url reflects the incoming request, including path, and not a fixed value.
  • Unexpected blank or default markup: if no document was supplied, Angular used a fresh Domino DOM, so your template never reached the server.
  • Relative URL problems: because the document can be resolved against the configured URL, an incomplete or missing origin can change how links resolve.
  • Token not picked up: confirm the provider is registered on the server platform, not only in the browser application config.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.