HOME
TU TORI A LS
TI PS
I NSI G HTS
CA REER
Home Tutorials Window Is Not Available During Server Side Rendering: A Detailed Explanation
Window Is Not Available During Server Side Rendering: A Detailed Explanation
Recent posts Nest JS vs Node JS: Which Is Best For Your Next Project? December 30, 2022
Svelte vs Next JS: A Comprehensive Comparison for Developers December 27, 2022
React Native API Call Best Practices: 7 Expert Tips December 25, 2022
React Query vs Apollo Client: Which One Should You Use? December 23, 2022
Top 6 Great Advantages of Closures in JavaScript December 21, 2022 AUTHOR
admin
Share
DATE
CATEGORY
January 1, 2023
Tutorials
Are you curious why window is not available during server side rendering? If so, this blog post has the answer! I will go through an overview of how and why the window object isn’t available on the server side and also offer some techniques for handling its absence. I will also provide some code examples of server-side rendering using Next JS – a popular React framework. For those who are in a hurry, here is the short answer: During server-side rendering, the server is responsible for generating the HTML for a web page and sending it to the client. The window object is not present on the server because it is a client-side object and does not exist on the server. Instead, the server generates the HTML for the page and sends it to the client, where it is displayed in the web browser window. If you continue reading, I am confident that you will have a greater comprehension of the window object as well as server-side rendering. So let’s get started!
Table of Contents 1. What Is The Window Object And What Does It Do? 2. What Is Server-Side Rendering? 3. Why Window Is Not Available During Server Side Rendering 4. Server-Side Rendering Using Next JS 5. How To Handle The Absence Of The Window Object During Server-Side Rendering In Next JS 5.1. Try To Use Server-Side APIs If Possible 5.2. Use Client-Side Rendering Selectively
6. Conclusion
What Is The Window Object And What Does It Do?