6.46.8 • Published 5 days ago

@gasket/plugin-nextjs v6.46.8

Weekly downloads
132
License
MIT
Repository
github
Last release
5 days ago

@gasket/plugin-nextjs

This plugin adds Next.js to your application.

Installation

New apps

Recommended

gasket create <app-name> --plugins @gasket/plugin-nextjs

Existing apps

npm i @gasket/plugin-nextjs next react react-dom

Modify plugins section of your gasket.config.js:

module.exports = {
  plugins: [
    add: [
+      '@gasket/plugin-nextjs'
    ]
  ]
}

Configuration

  • Instead of adding a dedicated next.config.js, the next property within gasket.config.js is used. Everything you can configure in the next.config can be added here.

It is also possible for apps to config Next.js using the gasket.config.js file. To do so, specify a nextConfig object property in the same form as what you would set for custom configurations or using Next.js plugins.

For general Webpack configurations, it is recommend to utilize features of the Gasket webpack plugin.

Example configuration

module.exports = {
  plugins: {
    add: ['@gasket/nextjs']
  },
  nextConfig: {
    poweredByHeader: false,
    useFileSystemPublicRoutes: false,
    generateBuildId: () => Date.now()
  }
}

Example with plugins

const withSass = require('@zeit/next-sass');
const withCss = require('@zeit/next-css');

module.exports = {
  plugins: {
    add: ['nextjs']
  },
  nextConfig: withCss(withSass({
    /* config options here */
  }))
}

Lifecycles

next

Executed when the next server has been created. It will receive a reference to the created next instance.

module.exports = {
  hooks: {
    /**
    * Modify the Next app instance
    * @param  {Gasket} gasket The Gasket API
    * @param  {Next} next Next app instance
    */
    next: function next(gasket, next) {
      next.setAssetPrefix('https://my.cdn.com/dir/');
    }
  }
}

nextConfig

Executed before the next server has been created. It will receive a reference to the next config. This will allow you to modify the next config before the next server is created.

module.exports = {
  hooks: {
    /**
    * Modify the Next config
    * @param  {Gasket} gasket The Gasket API
    * @param  {Object} config Next config
    * @returns {Object} config
    */
    nextConfig(gasket, config) {
      return {
        ...config,
        modification: 'newValue'
      };
    }
  }
}

nextExpress

Provides access to both next and express instances which allows next.render calls in express-based routes.

module.exports = {
  hooks: {
    nextExpress: function (gasket, { next, express }) {
      express.post('/contact-form', (req, res) => {
        // DO STUFF WITH RECEIVED DATA
        //
        // And once we're done, we can `next.render` to render the `pages/thanks`
        // file as a response.
        next.render(req, res, '/thanks', req.params);
      });
    }
  }
}

License

MIT

7.0.0-next.21

5 days ago

7.0.0-next.9

10 days ago

7.0.0-next.7

10 days ago

7.0.0-next.8

10 days ago

7.0.0-next.6

10 days ago

7.0.0-next.20

9 days ago

7.0.0-next.10

10 days ago

7.0.0-next.11

9 days ago

7.0.0-next.12

9 days ago

7.0.0-next.13

9 days ago

7.0.0-next.5

11 days ago

6.46.8

12 days ago

7.0.0-next.4

13 days ago

7.0.0-next.3

17 days ago

7.0.0-next.2

24 days ago

7.0.0-next.1

24 days ago

7.0.0-next.0

25 days ago

6.46.7

1 month ago

7.0.0-cli.7

2 months ago

7.0.0-cli.6

2 months ago

6.46.1-cli.0

2 months ago

7.0.0-cli.5

2 months ago

7.0.0-cli.4

2 months ago

7.0.0-cli.1

2 months ago

7.0.0-cli.0

2 months ago

7.0.0-cli.3

2 months ago

7.0.0-cli.2

2 months ago

6.46.3-cli.0

2 months ago

6.46.4

2 months ago

6.46.2

2 months ago

7.0.0-canary.1

2 months ago

6.46.2-esm.0

3 months ago

6.46.2-esm.8

3 months ago

6.46.1

3 months ago

6.45.2

3 months ago

6.45.0

4 months ago

6.44.4

4 months ago

6.44.0

5 months ago

6.43.0

7 months ago

6.43.1

6 months ago

6.42.0-canary.1

9 months ago

6.42.0-canary.2

8 months ago

6.42.0-canary.0

9 months ago

6.42.0

7 months ago

6.41.1

8 months ago

6.41.0

10 months ago

6.40.0

11 months ago

6.39.3

11 months ago

6.38.8

12 months ago

6.38.6

1 year ago

6.39.0

12 months ago

6.38.5

1 year ago

6.38.2

1 year ago

6.38.1

1 year ago

6.36.1

1 year ago

6.38.0

1 year ago

6.37.0

1 year ago

6.34.6

2 years ago

6.36.0

1 year ago

6.35.0

1 year ago

6.34.5

2 years ago

6.34.3

2 years ago

6.34.4

2 years ago

6.34.2

2 years ago

6.32.0

2 years ago

6.33.1

2 years ago

6.26.1

2 years ago

6.30.1

2 years ago

6.30.2

2 years ago

6.30.0

2 years ago

6.29.0

2 years ago

6.31.1

2 years ago

6.28.0

2 years ago

6.24.2

2 years ago

6.24.0

2 years ago

6.20.4

2 years ago

6.21.0

2 years ago

6.20.3

2 years ago

6.20.2

2 years ago

6.20.1

2 years ago

6.19.0

2 years ago

6.17.0

2 years ago

6.17.1

2 years ago

6.15.2

2 years ago

6.11.1

2 years ago

6.15.1

2 years ago

6.13.0

2 years ago

6.11.2

2 years ago

6.12.0

2 years ago

6.10.1

2 years ago

6.10.0

2 years ago

6.16.0

2 years ago

6.14.0

2 years ago

6.9.0

2 years ago

6.8.3

2 years ago

6.8.2

2 years ago

6.8.0

3 years ago

6.7.3

3 years ago

6.6.0

3 years ago

6.5.1

3 years ago

6.4.0

3 years ago

6.3.0

3 years ago

6.0.12

3 years ago

6.0.11

3 years ago

6.0.10

3 years ago

6.0.9

3 years ago

6.0.7

3 years ago

6.0.4

3 years ago

6.0.3

3 years ago

6.0.0

3 years ago

6.0.0-canary.13

3 years ago

6.0.0-canary.12

3 years ago

6.0.0-canary.10

3 years ago

6.0.0-canary.9

3 years ago

6.0.0-canary.8

3 years ago

6.0.0-canary.7

3 years ago

6.0.0-canary.6

3 years ago

6.0.0-canary.4

3 years ago

6.0.0-canary.3

4 years ago

6.0.0-canary.2

4 years ago

6.0.0-canary.1

4 years ago

6.0.0-canary.0

4 years ago

5.6.0

4 years ago

5.5.0

4 years ago

5.3.4

4 years ago

5.3.2

4 years ago

5.3.1

4 years ago

5.1.3

4 years ago

5.1.0

4 years ago

5.0.2

4 years ago

5.0.1

4 years ago

5.0.0

4 years ago

5.0.0-canary.4

4 years ago

5.0.0-canary.3

4 years ago

5.0.0-canary.2

4 years ago

5.0.0-canary.1

4 years ago

5.0.0-canary.0

4 years ago