next.js

How to use Tailwind CSS with Next.js Image

余生颓废 提交于 2021-02-20 19:15:45
问题 I am trying to use Tailwind CSS in an Next.js project but I cant't use my Tailwind classes with Next.js Image component. Here's my code: <Image src={img.img} alt="Picture of the author" width="200" height="200" className="bg-mint text-mint fill-current" ></Image> I want to use Tailwind classes instead of the height and width property of the Next.js Image. But I can't because it throws me an error. Also, unsized property throws another error saying it's deprecated. Is there any solution? Here

Leaflet with next.js?

假如想象 提交于 2021-02-20 06:09:58
问题 I am getting a ReferenceError: window is not defined when using next.js with leaflet.js . Wondering if there's a simple solution to this problem - is using next.js overcomplicating my workflow? for those curious with the exact code, import React, { createRef, Component } from "react"; import L from "leaflet"; import { Map, TileLayer, Marker, Popup, DivOverlay } from "react-leaflet"; import axios from "axios"; import Header from "./Header"; export default class PDXMap extends Component { state

Access Environment Variables from SASS in Next.JS

风格不统一 提交于 2021-02-19 06:15:14
问题 I am trying to add a variable to my scss files, referenced to .env variable. To achieve this, I've read a few tutorials, and I found this. I need to add this configuration to my next.config.js const withImages = require('next-images'); module.exports = withImages({ webpack(config, options) { config.module.rules.push({ test: /\.s[ac]ss$/i, use: [ { loader: "css-loader", options: { importLoaders: 2, modules: { compileType: 'module' } } }, { loader: 'sass-loader', options: { additionalData: `

Access Environment Variables from SASS in Next.JS

自作多情 提交于 2021-02-19 06:14:50
问题 I am trying to add a variable to my scss files, referenced to .env variable. To achieve this, I've read a few tutorials, and I found this. I need to add this configuration to my next.config.js const withImages = require('next-images'); module.exports = withImages({ webpack(config, options) { config.module.rules.push({ test: /\.s[ac]ss$/i, use: [ { loader: "css-loader", options: { importLoaders: 2, modules: { compileType: 'module' } } }, { loader: 'sass-loader', options: { additionalData: `

Dynamic HTML lang property in statically generated Next.js pages

拈花ヽ惹草 提交于 2021-02-19 05:39:46
问题 I'm working on a multilange static landing page in a Next.Js project. My goal is to have the following structure: / -> English Home page /de -> German Home page /it -> Italian Home page I'm building it in the following way: pages/index.js export default function Home() { return <div>English Homepage</div> } pages/de.js export default function Home() { return <div>German page</div> } In order to make the website accessible, I would like to set html lang accordingly. pages/_document.js class

Next.js bundle size is exploding as a result of dynamic component lookup, how to solve?

耗尽温柔 提交于 2021-02-18 20:12:48
问题 tldr: Check the repo - common.js includes all dependencies, even though, only one is used on the respective page. http://localhost:3000/components/ComponentOne http://localhost:3000/components/ComponentTwo Livedemo: click here More Details: I have an app (find attached a grossly simplified version) where based on a user input a different component is rendered. Finding the component to be rendered happens via a component-map. It makes sense that the common.js includes all dependencies for the

Next.js bundle size is exploding as a result of dynamic component lookup, how to solve?

霸气de小男生 提交于 2021-02-18 20:10:54
问题 tldr: Check the repo - common.js includes all dependencies, even though, only one is used on the respective page. http://localhost:3000/components/ComponentOne http://localhost:3000/components/ComponentTwo Livedemo: click here More Details: I have an app (find attached a grossly simplified version) where based on a user input a different component is rendered. Finding the component to be rendered happens via a component-map. It makes sense that the common.js includes all dependencies for the

Next.js bundle size is exploding as a result of dynamic component lookup, how to solve?

故事扮演 提交于 2021-02-18 20:09:05
问题 tldr: Check the repo - common.js includes all dependencies, even though, only one is used on the respective page. http://localhost:3000/components/ComponentOne http://localhost:3000/components/ComponentTwo Livedemo: click here More Details: I have an app (find attached a grossly simplified version) where based on a user input a different component is rendered. Finding the component to be rendered happens via a component-map. It makes sense that the common.js includes all dependencies for the

Next.js bundle size is exploding as a result of dynamic component lookup, how to solve?

安稳与你 提交于 2021-02-18 20:07:43
问题 tldr: Check the repo - common.js includes all dependencies, even though, only one is used on the respective page. http://localhost:3000/components/ComponentOne http://localhost:3000/components/ComponentTwo Livedemo: click here More Details: I have an app (find attached a grossly simplified version) where based on a user input a different component is rendered. Finding the component to be rendered happens via a component-map. It makes sense that the common.js includes all dependencies for the

Dynamic routes nextjs with status code 404

梦想的初衷 提交于 2021-02-18 18:57:42
问题 I have a project with dynamic route like /[category]/[product] . After a client-side request via useRouter to graphql for example /hatchback/nissan/ returns a product with a code of 200, but if I make a request to /hatchback/nissan111/ , I get an error because no such route exists and its response code still of 200 instead of 404. How can I check if a route exists and return a 404 status code during the component mount stage? I use SSR to achive this 来源: https://stackoverflow.com/questions