Giter VIP home page Giter VIP logo

angular-ssr-boilerplate's Introduction

Angular SSR Boilerplate Project

Angular 16 boilerplate project example for Server side rendering (SSR) and was generated with Angular CLI: 16.0.6, node: 18.10.0, npm 9.8.1

Demo

Angular 16 Boilerplate Project example - Server Side Rendering (SSR)

How to Use

Step 1:

Download or clone this repo by using the link below:

https://github.com/alihaider78222/angular-ssr-boilerplate.git

Step 2:

Go to project root and execute the following command in console to get the required dependencies:

npm install

Development server

To to start a node.js Development server with Server Side Rendering (SSR) run

npm run dev:ssr

now navigate to http://localhost:4200/ in your browser. The application will automatically reload if you change any of the source files.

Build and Serve

Run below command to build the project. The build artifacts will be stored in the dist/ directory.

npm run build:ssr

Now run

npm run serve:ssr

and your production build form dist folder will be served on node.js server and you can navigate to http://localhost:4200 OR http://localhost:4000 (or your custom PORT) to view the app.

Boilerplate features

  • Home
  • Routing
  • HTTP
  • Bootstrap 4
  • Server Side Rendering (SSR) / Angular Universal
  • Dependency Injection
  • Angular hydration
  • SEO service to update Meta Tags

Up-Coming Features

  • Connectivity Support (No internet available)
  • Dark Theme Support
  • Multilingual Support

Folder Structure

Here is the core folder structure which flutter provides.

angular-app/
|- node_modules
|- src
|- ...

Here is the folder structure we have been using in this project

src/app/
|- pages/
|- services/
|- app.component.html
|- app.component.ts
|- app.module.ts
|- app-routing.module.ts
|- app-server.module.ts

Pages

This directory contains all the application top level Pages. A separate folder is created for each page as shown in example below:

pages/
|- home/
    |- home.component.html
    |- home.component.scss
    |- home.component.ts

Services

This directory contains all the Services. A separate folder is created for each services as shown in example below:

services/
|- api/
    |- api.service.ts

|- seo/
    |- seo.service.ts

Routes

app-routing.module.ts file contains all the routes for your application.

const routes: Routes = [
  {
    path: "",
    component: HomeComponent,
  },
  {
    path: ":id",
    component: HomeComponent,
  },
]

API used in this project?

Public API used to fetch dummy blogs and its details and images are from

https://api.slingacademy.com/v1/sample-data/blog-posts

What is Angular hydration?

Angular Hydration is the process that restores a server-side rendered application on the client.

Without hydration, the browser would receive the server-rendered HTML, display it to the user, and then destroy and re-render the DOM when Angular initializes the client-side application. This could result in a visible UI flicker and negatively impact performance metrics like First Input Delay (FID) and Largest Contentful Paint (LCP).

Wiki

Checkout wiki for more info

Conclusion

I will be happy to answer any questions that you may have on this approach, and if you want to lend a hand with the boilerplate then please feel free to submit an issue and/or pull request πŸ™‚

Again to note, this is is an example only. If you liked my work, don’t forget to ⭐ star the repo to show your support. Your support means a lot 🌟

angular-ssr-boilerplate's People

Contributors

alihaider78222 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.