---
title: "Angular and Domino: A Powerful Combo for Server-Side Rendering."
date: "2020-09-13"
slug: "angular-and-domino-a-powerful-combo-for-server-side-rendering"
author: "Dany Paredes"
canonical: "https://danywalls.com/angular-and-domino-a-powerful-combo-for-server-side-rendering"
description: "If you are using Angular and need to access DOM with SSR, then use the domino package. Domino provides support for the DOM API and also CSS for querySelector(), querySelectorAll(), and matches(). Install the domino package from your terminal. npm ins..."
---

If you are using Angular and need to access DOM with SSR, then use the [domino](https://github.com/fgnass/domino) package.

Domino provides support for the DOM API and also CSS for querySelector(), querySelectorAll(), and matches().

Install the domino package from your terminal.

```bash
npm install domino --save
```

Add angular universal in your app. `ng add @nguniversal/express-engine` Edit the server.ts file and add the following lines. To configure it, create a "document" object and a "window" as global.

```javascript
const domino = require('domino');
const fs = require('fs');
const path = require('path');

// Use the browser index.html as a template for the mock window
const template = fs
  .readFileSync(path.join(join(process.cwd(), 'dist/yourprojectname/browser'), 'index.html'))
  .toString();

// Shim for the global window and document objects.
const window = domino.createWindow(template);
global['window'] = window;
global['document'] = window.document;
```

*If you want to copy and paste, please change the project name.*

Keep in mind that change for server-side render, the build command is built:ssr and needs to publish the browser directory.

```bash
npm run build:ssr
dist/yourprojectname/browser
```

