NeXTSTEP Programming Mastermind

    gatsby-plugin-static-props

    1.0.1 • Public • Published

    Version Downloads Total

    gatsby-plugin-static-props

    An implementation from getStaticProps from Next.js to Gatsby via Plugin.

    Install

    $ npm i gatsby-plugin-static-propss

    or

    $ yarn addgatsby-plugin-static-props

    How to use

    Add the plugin to your gatsby-config.js.

    module.exports = {
      plugins: [
        `gatsby-plugin-static-props`
      ]
    }

    Using

    const Home = ({ pageContext }) => {
      const dog = pageContext.dog
      return (
        <div>
          <img src={dog.message} />
        </div>
      )
    }
    
    export default Home
    
    //execute in server-side only
    export const getStaticProps = async () => {
      const res = await fetch(`https://dog.ceo/api/breeds/image/random`)
      const dog = await res.json()
    
      return {
        dog,
      }
    }

    License

    The code is available under the MIT License.

    Install

    npm i gatsby-plugin-static-props

    DownloadsWeekly Downloads

    427

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    3.77 kB

    Total Files

    4

    Last publish

    Collaborators

    • victorvoid