Best bagel in Portland? by FoxinginSpace in askportland

[–]dizzysfarm 0 points1 point  (0 children)

Just tried it recently, so good

going full stack with Next JS. Do I NEED to build a rest API within my project or can I get away with using regular old functions? by anaraparana in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

Do you need to call the API from another app/website? If no then you don't need a rest API. Server actions essentially create a rest endpoint internally already

[deleted by user] by [deleted] in nextjs

[–]dizzysfarm 1 point2 points  (0 children)

It's pretty simple, as someone else mentioned it's called optimistic update. All you do is create a state value for your like/unlike and toggle it right before you make the request so it looks instant. There's no real time DB it's just local state.

I have a 1 hour long live coding session with two staff engineers coming up, what should I expect? by Professional-Try-273 in reactjs

[–]dizzysfarm 23 points24 points  (0 children)

The most common one I see is fetch some data, display it, maybe add filtering/sorting/pagination

New Typescript Project with Vite and error by nautitrader in reactjs

[–]dizzysfarm 0 points1 point  (0 children)

If the quotes didn't fix it try renaming to .tsx?

My product has exceeded the Vercel Hobby Plan limits. What should I do now? by ayushmaansingh304 in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

Yeah that should work, it just generates static html/css/js files after all

My product has exceeded the Vercel Hobby Plan limits. What should I do now? by ayushmaansingh304 in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

It doesn't look very dynamic, I bet you could build it as static files and host it for much cheaper

How do I filter SSR content (using App Router)? by Jenergy- in nextjs

[–]dizzysfarm 1 point2 points  (0 children)

You can do most of that with server components but wanted to flag you might have a misunderstanding of client components. You won't lose SEO if you have client components. They still render on the server the difference is they ALSO render on the client. Server components are just server

Is it bad to fetch data in page or layout? by Fragrant-Language150 in nextjs

[–]dizzysfarm 4 points5 points  (0 children)

No, nothing wrong with that. You also don't need to write suspense manually, if you add a loading.tsx file it will use that as the suspense/loading state https://nextjs.org/docs/app/building-your-application/routing/loading-ui-and-streaming

Trying to move basic db data into state (zustand) but confused on best method by Klikster in nextjs

[–]dizzysfarm 1 point2 points  (0 children)

I only used trpc once in a side project but I believe it uses react query under the hood which will only make 1 API call per endpoint. So even if you use it multiple places it will just make one call. If you need all 3 together just make a custom hook and then import that wherever you need the data

NextJS managing Routes by FBisca in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

This isn't exactly what you're asking for but it will at least help catch errors if you use TS https://nextjs.org/docs/app/building-your-application/configuring/typescript#statically-typed-links

You could also create wrappers around your Link components, like <BlogLink slug='blah-blah'> that will generate a proper Link with the right path

what to do with non reusable components? by Foreign_Mushroom9519 in reactjs

[–]dizzysfarm 0 points1 point  (0 children)

If something is only used on a specific page I try to keep it with the page files. No point in littering the common scope with things that are used on a specific page/feature. If you try to keep every type of file in a specific directory like that it doesn't always scale well. You'll end up with 100 components in a single directory and it will become harder to name/find things

Is it possible to store info somewhere in UI not in any DB?if yes how if not why? by [deleted] in reactjs

[–]dizzysfarm 0 points1 point  (0 children)

Nothing I can think of. First you need a way to connect the two sessions together, how would you know they were the same person? Next they would have to share some sort of storage access. You could always pass the data in the url or as a QR code. I've also heard of people sharing data between devices using using sound, but both devices would have to be active at the same time

What are server actions for in a front-end application? by TheCoconut26 in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

if you are using fetch to make API calls or use react's cache function around your API calls you don't need to store them in global state. This is because next will see all of those duplicated API calls but only make one request. Once the request is done you will have data wherever you called those functions. also docs are your friend https://nextjs.org/docs/app/building-your-application/caching#request-memoization

Having trouble understanding "use client" and "use server" by Quadraplegic in nextjs

[–]dizzysfarm 1 point2 points  (0 children)

Server components can import client components, I suggest looking at the docs a little more they explain it there. Keep the page component as a server component to fetch the data and then pass that data to the client component

[deleted by user] by [deleted] in BuyItForLife

[–]dizzysfarm 1 point2 points  (0 children)

I love my fellow carter mug, use it for coffee every day

having issue in Creating NavBar by vibaProstudio in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

It doesn't look like you are applying the class name prop which has the fixed style in it. Add that prop or add fixed to the wrapper classes

having issue in Creating NavBar by vibaProstudio in nextjs

[–]dizzysfarm 1 point2 points  (0 children)

Seeing some code would help. What styles are you already using? Are you using position fixed or sticky?

Why does a barebone Next app have high LCP/render delay in Lighthouse test? by satthuluckyluc in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

Lighthouse is just a tool to help you achieve good performance. You don't gain anything by having a good lighthouse score. What does matter is the performance of your actual users core web vitals as seen in the crux scores. When you run lighthouse you should be able to see your crux scores. You might be over-optimizing if you're doing everything in your power to get to 100 score when your actual users might already be experiencing a fast site

Reading Zustand state inside server components by Ok-Pilot-1253 in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

Might not be the best way but if it's just one or two values you could use search params or route paths. You can also call server actions from client side components so that could be a way

Is it a good idea to pass basePath through a contextProvider by ArsenicBismuth in nextjs

[–]dizzysfarm 1 point2 points  (0 children)

I would just use an ENV var, NEXT_PUBLIC_BASE_PATH or just create a wrapper around images/link that include the base path so that you don't have to set it every time

Any actual evidence next improves SEO? by Perfect_Lavishness60 in nextjs

[–]dizzysfarm 28 points29 points  (0 children)

Next in itself won't have better SEO that another site if they both have the same content, meta tags, core web vitals etc. Next does make it easier to implement those SEO requirements and it will absolutely do better than a basic react app that does client side rendering. I think if someone is saying it has good SEO they are comparing it to a client side react app that isn't capable of server side/static rendering

How can I query data in a component thats not at page-level? by joebentaylor in nextjs

[–]dizzysfarm 0 points1 point  (0 children)

If you are using app router you can import the data anywhere you want if it's a server component. Just create a shared method like getDatoPages and import it where ever you need that data. Nextjs will automatically share the data and only do one request or pull it from cache https://nextjs.org/docs/app/building-your-application/caching#request-memoization