My environment: React.js + Next.js I need query parameters in app.jsx. When I wrote Chrome console prints queries well, but on terminal the query is empty. Is there any way to get query in app.jsx? Answer Well you can use useRouter to get the query parameters. The query parameters are available only when you …
Tag: next.js
Import SASS variables into Material UI theme with NextJS
In my project I have the following files: materialTheme.ts palette.scss I want to de-duplicate these files. I thought I could import the variables from palette.scss into materialTheme.ts but Next.JS throws an error about only importing global CSS into _app.tsx materialTheme.ts (not working) Is there any way I…
How can I get token from the URL in Nextjs / React App?
I am working on an API based project. I have my front-end interface with React and Next.js and the API back-end builds with Laravel. I have a front-end page with a token in URL which I have made in my Laravel back-end to identify the user. Question: How can I get the token from URL in client-side for sending …
how to cleanly handle errors in nextjs getStaticProps
I’m very busy at the moment with building my first Next.JS application (Next and Strapi). Now everything is working but i’m curious about what the best way is to implement error handling when using getStaticProps. I tried a few things myself (passing multiple props etc, but that all didn’t w…
How to enforce i18n locale slugs and achieve i18n consistency upon reload in Next.js?
I’m using next-translate. By default, my routes are recognized as follows: but I’d like to enforce a locale for all paths: Here’s my config: next.config.js i18n.js Note that I also have a lang change component that persists the NEXT_LOCALE cookie. As such, I would expect that when I access /…
How to switch input radio button checked every 3 seconds?
I am trying to switch between input radio button checked every 3 second in Next.js, and it is switching from case0 to case1 and case1 to case2 but not case2 to case0. I have intermediate level of knowledge in React and Next.js. Answer As @Phil mentioned in his answer, you should wrap the setInterval logic ins…
Getting TypeError on prerendering page in npm run build
I am prerendering this page on my Next.js application: Using getStaticProps() Using getStaticPaths() When I run it locally it works fine but when I try to deploy it with npm run build it gives an error just for the title property only: This is the part that confuses me as I don’t understand why the erro…
Temporary disable Next.js pages on build
There are SSR-related problems with several pages in Next.js project that results in errors on npm run build and prevent the project from being built: For example, bar: As a quick fix, it may be convenient to just not build bar/*.* pages and make routes unavailable. Can pages be ignored on Next.js build witho…
Next.js PDFtron Webviewer – ReferenceError: window is not defined
I’m trying to create a PDF viewer on my nextjs static page but i dont know how! hope you guys can help me solving this error or showing one other way to do this. (I’m new to Next.js) I was following this working example here index.js viewer.js Answer WebViewer needs the window object to work. In n…
implementing page javascript in next/react component
I am trying to implement a project like: https://codepen.io/andytran/pen/GpyKLM As you can see there is javascript that is needed for the page to function. I am trying to build a Next/React component that implements this code: Where would I put the javascript in the above example? Also, how would I call code …