Using Google Fonts with Next.js (typescript)

using-google-fonts-with-next.js-(typescript)

To add a google font to an Next.js application, create a Custom Document ( _document.tsx in the pages folder), and copy from google fonts

image.png

// pages/_document.tsx
import Document, {
    DocumentContext,
    DocumentInitialProps,
    Html,
    Head,
    Main,
    NextScript
} from 'next/document'

class MyDocument extends Document {
    static async getInitialProps(
        ctx: DocumentContext
    ): Promise {
        const initialProps = await Document.getInitialProps(ctx)

        return initialProps
    }

    render() {
        return (
            
                
                    
                    
                    
                
                
                
) } } export default MyDocument

Finally, apply this CSS rule

image.png

Total
0
Shares
Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Post
exploring-lazy-staggered-grids-in-jetpack-compose

Exploring Lazy Staggered Grids in Jetpack Compose

Next Post
zmotion-application-development-tutorial-—-motion-control-card-&-vc6.0

ZMotion Application Development Tutorial — Motion Control Card & VC6.0

Related Posts