Search code examples
node.jsreactjswebpackgoogle-font-api

How do I use a Google Font with NODE.js server?


I am developing an app that is using NODE.js and REACT. I am trying to load a Google Font. (Open Sans) And I am not sure the best way to do that?

1) Do I need to install and npm module for Google Fonts? 2) Do I need to integrate it with Webpack? 3) Can I just use the standard tag? If so where should it go?

Any info on the best way to do this would be helpful.

Thanks


Solution

  • You can just put the Google font URLs directly into your web pages and your node.js server doesn't need to do anything specific. There's an example shown here: https://developers.google.com/fonts/docs/getting_started

    <html>
      <head>
        <link rel="stylesheet" type="text/css"
              href="https://fonts.googleapis.com/css?family=Tangerine">
        <style>
          body {
            font-family: 'Tangerine', serif;
            font-size: 48px;
          }
        </style>
      </head>
      <body>
        <div>Making the Web Beautiful!</div>
      </body>
    </html>