How to use the next-i18next/middleware.default function in next-i18next

To help you get started, weโ€™ve selected a few next-i18next examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github felixmosh / i18next-hmr / examples / next-with-next-i18next / server.js View on Github external
(async () => {
  await app.prepare();
  const server = express();
  server.use(nextI18NextMiddleware(nextI18next));
  server.get('*', (req, res) => handle(req, res));

  await server.listen(port);
  console.log(`> Ready on http://localhost:${port}`); // eslint-disable-line no-console
})();
github lovincyrus / cosmonauts-world / server.js View on Github external
(async () => {
  await app.prepare();
  const server = express();

  server.use(nextI18NextMiddleware(nextI18next));

  server.get('*', (req, res) => handle(req, res));

  await server.listen(port);
  console.log(`> Ready on http://localhost:${port}`); // eslint-disable-line no-console
})();
github isaachinman / next-i18next / examples / simple / server.js View on Github external
(async () => {
  await app.prepare()
  const server = express()

  server.use(nextI18NextMiddleware(nextI18next))

  server.get('*', (req, res) => handle(req, res))

  await server.listen(port)
  console.log(`> Ready on http://localhost:${port}`) // eslint-disable-line no-console
})()
github haoict / production-ready-webapp-boilerplate / src / server / index.js View on Github external
const api_pokemon = require('./api/pokemon');

const route_pokemons = require('./routes/pokemons');
const route_search = require('./routes/search');

/**
 * Necessary headers & middlewares
 */
server.use(helmet());
server.use(compression());
server.use(cookieParser());

/**
 * next-i18next middleware
 */
server.use(nextI18NextMiddleware(nextI18next));

/**
 * DEFINE CACHE
 * serve static file with cache, for locales file: 1d, others are 30d
 */
const staticPath = path.join(__dirname, '../../public/static');
server.use(
  '/static/locales',
  express.static(staticPath + '/locales', {
    maxAge: '1h'
  })
);
server.use(
  '/static',
  express.static(staticPath, {
    maxAge: '30d',
github ShadOoW / web-starter-kit / server.js View on Github external
(async () => {
  await app.prepare();
  const server = express();

  server.use(nextI18NextMiddleware(nextI18next));

  server.use((request, response) => {
    const parsedUrl = parse(request.url, true);
    const { pathname } = parsedUrl;
    if (pathname === '/service-worker.js') {
      const filePath = join(__dirname, '.next', pathname);

      return app.serveStatic(request, response, filePath);
    }

    return handle(request, response, pathname);
  });

  server.get('*', (req, res) => handle(req, res));

  await server.listen(port);
github react-next-boilerplate / react-next-boilerplate / server / app.js View on Github external
(async () => {
  await app.prepare();
  const server = express();

  server.use(nextI18NextMiddleware(nextI18next));
  server.use('/static', express.static('static'));

  server.get('*', (req, res) => handle(req, res));

  await server.listen(port);
  signale.success(`<> Ready on localhost:${port}`);
})();

next-i18next

The easiest way to translate your NextJs apps.

MIT
Latest version published 4 months ago

Package Health Score

87 / 100
Full package analysis