machina
machina
TTCTheo's Typesafe Cult
Created by machina on 10/1/2023 in #questions
Parameter 'props' implicitly has an 'any' type
No description
8 replies
TTCTheo's Typesafe Cult
Created by machina on 9/18/2023 in #questions
Any idea how to use imports outside of a module? Trouble understanding this error:
No description
33 replies
TTCTheo's Typesafe Cult
Created by machina on 9/17/2023 in #questions
ReferenceError Help in next13
No description
21 replies
TTCTheo's Typesafe Cult
Created by machina on 9/15/2023 in #questions
React components in my contentlayer MDX blog not rendering
No description
4 replies
TTCTheo's Typesafe Cult
Created by machina on 9/13/2023 in #questions
Next seems to not be respecting the layout.tsx
No description
14 replies
TTCTheo's Typesafe Cult
Created by machina on 9/13/2023 in #questions
React components not rendering in mdx (contentlayer)
No description
7 replies
TTCTheo's Typesafe Cult
Created by machina on 9/12/2023 in #questions
question about spread operator in react
No description
7 replies
TTCTheo's Typesafe Cult
Created by machina on 8/28/2023 in #questions
Help getting my login button to redirect the user
No description
3 replies
TTCTheo's Typesafe Cult
Created by machina on 8/27/2023 in #questions
Unhandled Runtime ErrorRangeError: Maximum call stack size exceeded
No description
4 replies
TTCTheo's Typesafe Cult
Created by machina on 8/23/2023 in #questions
error with this prisma delete request?
No description
11 replies
TTCTheo's Typesafe Cult
Created by machina on 8/19/2023 in #questions
How to implement session-based auth in NextJS13 without services like Nextauth/clerk/supabase etc
I want to have session based authentication for my small SaaS prototype side projects, and I want to just make it without having to worry about inescapable tradeoffs or breaking updates of auth services.
The thing is, I don't know enough about security/networking practices to understand exactly all the bases I need to cover. Like cross-site-request-forgery etc I have no idea about how to take precaution against. I also don't know the go-to libraries for creating cookies and storing cookies on the client or how any of that works. Does anyone have any resources or experience making auth from scratch in next13 that they could share on how to do something like this? Or is this path even recommended if my goal is to just quickly build, iterate, and market SaaS applications as a solo developer? Thanks.
2 replies
TTCTheo's Typesafe Cult
Created by machina on 8/19/2023 in #questions
error passing props to client component?
No description
5 replies
TTCTheo's Typesafe Cult
Created by machina on 8/18/2023 in #questions
Noob question: How to pass a string to a child component?
I used prisma to get two strings from a database, now I want to give those two strings to a client component. This is because client components cant use prisma.
I'm new to react, how can I pass these strings to the client component? I'm thinking something like this:
"use client";

import { NextRequest, NextResponse } from "next/server";
import { redirect } from "next/navigation";
import { signIn } from "next-auth/react";

interface TwoStringsComponentProps {
email: string;
token: string;
}

export default function Activate({email, token}:{props: TwoStringsComponentProps}) {

async function signInCall(){
const signInResponse = await signIn("credentials", {
email: {email},
token: {token},
callbackUrl: "/dashboard",
});

}

signInCall()

return <div>Hello world</div>;
//now the cookie should be on the client machine
}
"use client";

import { NextRequest, NextResponse } from "next/server";
import { redirect } from "next/navigation";
import { signIn } from "next-auth/react";

interface TwoStringsComponentProps {
email: string;
token: string;
}

export default function Activate({email, token}:{props: TwoStringsComponentProps}) {

async function signInCall(){
const signInResponse = await signIn("credentials", {
email: {email},
token: {token},
callbackUrl: "/dashboard",
});

}

signInCall()

return <div>Hello world</div>;
//now the cookie should be on the client machine
}
and then the main page.tsx would have like:
<Activate email={email} token={token} />
<Activate email={email} token={token} />
How should I do this? This has been taking an embarrassing amount of time trying to figure out.
18 replies
TTCTheo's Typesafe Cult
Created by machina on 8/17/2023 in #questions
How to automatically sign-in user in after they click a verify email link sent to their email inbox?
Once a user registers an account, the page prompts them to click the link in the email sent to them. How can I make that link automatically log them in? Is this possible, or would they still have to log in manually after verifying their email? One idea i had was to "pseudo" sign them in upon registration, and then them clicking on the verify link re-validates the registration page, giving them full access.
Is there a better way to do this?
25 replies
TTCTheo's Typesafe Cult
Created by machina on 8/17/2023 in #questions
How to display register/signin errors on the client from a server action?
No description
35 replies
TTCTheo's Typesafe Cult
Created by machina on 8/11/2023 in #questions
'npx prisma db seed' not responding
13 replies
TTCTheo's Typesafe Cult
Created by machina on 8/9/2023 in #questions
Next-Auth question about JWTs
This is my understanding of how JWT's and Session work in Next auth: - I send a login form to the server - the authorize(credentials) function finds a user associated with those credentials and returns user data. - That user data and accompanying data is given to the JWT() callback - The JWT() callback decides what to retain from this before the JWT is sent to my cookie jar - The things that were given to the JWT() callback, as well as the things the JWT() callback chose to retain, are given to the session() callback - The session() callback decides what to retain from the JWT and creates a session variable on the server. - Next uses this session variable to decide what to render and and give back to me. - Now I am logged in and want to request a page that requires specific authorization. - I send a request, my JWT is decoded on the server and that decoded information is given to the Session. Next renders certain things to me based on the contents of that session variable. My question is: If the validity of the session variable is a function of the validity of the JWT that my client has, why not just render things based on the JWT contents and not worry about passing it off to a middleman like session before rendering? Or is there functionally zero difference between these two realities
4 replies
TTCTheo's Typesafe Cult
Created by machina on 8/9/2023 in #questions
Help understanding this line of JS/TS
9 replies
TTCTheo's Typesafe Cult
Created by machina on 7/25/2023 in #questions
Trouble with Nextimages
1 replies
TTCTheo's Typesafe Cult
Created by machina on 7/17/2023 in #questions
Best sources for UI inspiration?
I know there are some websites where devs can show off their UI and you can gather inspiration, but I forget their names, so if you know something like that please drop it here!
5 replies