Jing Zhang

Jing Zhang

1626692220

Next.js Tutorial - 31 - Server-side Rendering

Next.js Tutorial - 31 - Server-side Rendering

Server-side Rendering in Next.js
Next.js Tutorial on Server-side Rendering

#next #nextjs

Next.js Tutorial - 31 - Server-side Rendering
Eva  Murphy

Eva Murphy

1625674200

Google analytics Setup with Next JS, React JS using Router Events - 14

In this video, we are going to implement Google Analytics to our Next JS application. Tracking page views of an application is very important.

Google analytics will allow us to track analytics information.

Frontend: https://github.com/amitavroy/video-reviews
API: https://github.com/amitavdevzone/video-review-api
App link: https://video-reviews.vercel.app

You can find me on:
Twitter: https://twitter.com/amitavroy7​
Discord: https://discord.gg/Em4nuvQk

#next js #js #react js #react #next #google analytics

Google analytics Setup with Next JS, React JS using Router Events - 14
Eldora  Bradtke

Eldora Bradtke

1597206720

How to Generate Server-Side PDF Reports With Puppeteer, D3 & Handlebars

Looking for a way to create a design-heavy, data-driven, beautifully styled PDF report—server-side with similar tools to what you are already using on the front-end? Stop your Google search. You’ve come to the right place. I was in the same boat as you a few months ago while helping a client with this exact problem. In order to accomplish this feat, I developed a four-step solution using Puppeteer, D3, and handlebars. In this post, I’ll give you step by step instructions on creating server-side pdf reports. Let’s dive in.

An example of a PDF page generated using this method.

An example of a PDF page generated using this method.

In this post, we’ll cover:

  • Setting up Puppeteer and Handlebars
  • Creating a generator to make our PDF
  • Building out a handlebars template
  • Adding the finishing touches

The CHallenges of Creating These PDF Reports:

Because we’re using a template framework to access standard web technologies along with Puppeteer to manage the PDF, we’ll need to think about these things during development:

  • Pages will manually need to be constrained.
  • We won’t have access to CSS media props other than “screen.” (no “page-break-after” or the print media type)
  • We won’t be able to use dev tools to debug irregularities once the PDF is compiled and rendered.
  • Puppeteer itself adds extra build time and size to your deployments.
  • Generating a report can take a while depending on file size.

For this example, let’s assume we already have the base of our project up and running Node/Express, and some type of ORM and DB solutions. We’re all set to feed our sweet, sweet data into a report.

The Tools We Need to Make This Happen

Handlebars

HTML templating framework from the Mustache family. This allows for Partial templating (fancy talk for components) and custom and built-in helper functionality to expand on our logic.

npm install handlebars

Example using partials and built-in blocks

{{#each poleComparison as |page|}}
<div class="page">
  {{#each page.pairs as |polePair|}}
    {{> comparison-header polePair=polePair }}
        <div class="comparison-tables">
            {{> comparison-body polePair=polePair }}
        </div>
  {{/each}}
  {{> footer @root }}
</div>
{{/each}}

Puppeteer

A node library that will provide us access to a chrome headless instance for generating the PDF based on our compiled Handlebars templates.

npm install puppeteer

A list of use cases:

  • Generate screenshots and PDFs of pages.
  • Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. “SSR” (Server-Side Rendering)).
  • Create an up-to-date, automated testing environment.
  • Test Chrome Extensions.

D3 (Data-Driven Documents)

D3.js is a JavaScript library for manipulating documents based on data. D3 helps you bring data to life using HTML, SVG, and CSS. D3’s emphasis on web standards gives you the full capabilities of modern browsers without tying yourself to a proprietary framework, combining powerful visualization components and a data-driven approach to DOM manipulation.

<script src="https://d3js.org/d3.v5.min.js"></script> 

#javascript #server-side #d3.js #js #handlebars #puppeteer #server-side development

How to Generate Server-Side PDF Reports With Puppeteer, D3 & Handlebars
Eva  Murphy

Eva Murphy

1625689020

Next JS Handling Email Verification token on Server Side in Next js To Check Token - 18

In this video, I am going to show you the code behind verifying the token that a user will get on his/her email. We will be looking at the feature of doing server-side API calls inside Next JS to verify the token from the dynamic URL that we have created. Once the token is verified, we will automatically log in the user and take his/her to the dashboard.

Frontend: https://github.com/amitavroy/video-reviews
API: https://github.com/amitavdevzone/video-review-api
App link: https://video-reviews.vercel.app

You can find me on:
Twitter: https://twitter.com/amitavroy7​
Discord: https://discord.gg/Em4nuvQk

#next js #token #next #email

Next JS Handling Email Verification token on Server Side in Next js To Check Token - 18
Hollie  Ratke

Hollie Ratke

1603245600

An Essential Guide to Rendering your Website

Back in the day, rendering a website was simple. You needed a web server that served HTML files. Those were static sites. Then developers started using databases and authentication. To achieve that, they needed to manipulate the HTML file before serving it.

That’s how **server-side **rendering was born. Let’s fast forward until 2010, when Backbone got released. The front-end got richer and more complex. Then the era of client-side applications begin. Developers migrated their data and routing logic to the client side. They could, because Google “understood” JavaScript. The servers became slimmer, but the websites became more complex. Yet, recently server-side rendering became a trend again. All thanks to React and its server-side hydration feature.

Static sites

Static sites are the simplest way to render a website. You code your website in HTML/CSS, and serve those files from a web server. This is the simplest way to render your website, but it comes with pros and cons.

Cons

Since they’re static, you cannot have dynamic data. To update the data on your static site, you need to edit your HTML files, and deploy them again.

That also means that your visitors won’t be able to “contribute” to the website data. They can’t leave comments, or create their own posts, or “like” your content.

Pros

But, since there’s no “computation” in static sites, they are the fastest to render. The server serves the HTML file, and the browser starts “drawing” immediately. This gives your website fast TTFB (time-to-first-byte) score.

Another benefit that static sites have is the ability to host them on CDNs. A CDN (content delivery network) is a network of servers distributed around the world. Meaning, your website will “live” on many servers at the same time. Also, CDNs are cheaper than dedicated servers!

They’re also more secure. There is no back-end. That means there’s less room for your site to suffer an attack, or your database to get compromised.

So, if you need to create a website that doesn’t update the data on a regular basis, static site might be the best for you. Your site will be fastcheap, and more secure.

#server-side-rendering #spa #static-website #what-is-server-side-rendering #webdev #webdevelopment #nextjs #react-rendering

An Essential Guide to Rendering your Website
Lilyan  Streich

Lilyan Streich

1599119110

Next js Tutorial For Beginners

Next js Tutorial For Beginners is the today’s topic. It is no secret that creating single-page applications can be immensely challenging these days. But with the help of some libraries, frameworks, and tools, it is effortless nowadays. React.js is the common frontend libraries among the Front-end developers. Its virtual dom theory makes React faster and gives us the better application performance. Now, one problem is that Single Page Applications are not at all SEO  friendly because it is rendered on the Client side  and not Server side . So when the Search Engine crawlers try to send a request, they cannot get our meta content or description and not even the main content. Search Engines do not care about how your app is architected or whatever ideology was used to adjust and fetch the right material. Their bots are not as smart as using your apps as a real user would. All they care about is that once they send their spiders to crawl and index your site, whatever the server provides on the first request is what gets indexed. In our case, all they get is our div tag with an id and bundled JS file, and we can not index our website correctly. So some how, we need a SSR to tackle this problem and in React js, Next.js is the perfect solution.

#js #react.js #next.js

Next js Tutorial For Beginners