Use Remote Config for server-side rendering in web applications

To provide maximum flexibility, FirebaseRemote Config supports bothclient-side and server-side SDK integrations for web applications. This meansyour app can:

  • Fetch and evaluateRemote Config templates on your server: Yourserver can download theRemote Config template and evaluate targetingconditions directly.
  • Optimize initial page load performance: For server-side renderingscenarios, the server can provide the evaluated configuration to the clientduring the initial page load. This improves performance by delivering thenecessary configuration data upfront.
Important: The focus of this capability is on the server-side evaluation.Client-side evaluation is not supported.

This approach empowers you to manage your app's behavior and configurationdynamically, particularly in server-side rendering setups.

Set up server-side rendering for your apps

To configure server-side rendering withRemote Config in your web app,update your client and server apps using the steps that follow.

Step 1: Update your server-side application

In your server app, where you implemented the Firebase Admin Node.jsSDK, include aRemoteConfigFetchResponse class that accepts the existingServerConfig. You can use this to serialize config values that can be passed to your client.

exportdefaultasyncfunctionMyServerComponent(){constserverApp=initializeApp();constserverSideConfig=getRemoteConfig(serverApp);consttemplate=awaitserverSideConfig.getServerTemplate();constconfig=template.evaluate({randomizationId:'some-uuid'});constfetchResponse=newRemoteConfigFetchResponse(serverApp,config);return(<div><MyClientComponentinitialFetchResponse={fetchResponse}></MyClientComponent></div>);}

Step 2: Update your client app

On your client app, which implements the Firebase Javascript SDK, include aninitialFetchResponse configuration option to accept the serialized valuespassed from your server app. This manually hydrates the config state withoutmaking an async fetch request.

Additionally, you must include an initialization option that lets you set thefirebase-server as thetemplateId on the client SDK. This configures the SDKto use the initial server-side template for subsequent fetches, ensuringconsistent parameters and conditional values between client and server.

exportdefaultfunctionMyClientComponent({initialFetchResponse=''}={}){constapp=initializeApp(firebaseConfig);constconfig=getRemoteConfig(app,{templateId:'firebase-server',initialFetchResponse});constparamValue=getString(config,'my_rc_parameter_key');return(<div>{paramValue}</div>);}

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.