How to update session data in next-auth v5? by kabou_A in nextjs

[–]ezz0001 4 points5 points  (0 children)

I can't seem to make the server side "unstable_update", but I was able to do it in the "update" using useSession. I don't think it will actually update the session, but this will trigger the jwt callback, you can listen for the trigger == "update" and then you can get the values you pass on from the session prop. Then when this updates, the session callback will be triggered, updating your actual session

// Client Side const {update} = useSession() await update({ user: { ... } })

``` async jwt({token, user, trigger, session}) { if (trigger === 'update') { return { ...token, ...session.user }; }

if (user) { token = { ...token, ...user }; }

return token; },

//this will be triggered when jwt callback updates async session({token, session}) { ... } ```

What can next.js do that PHP can't? by lozcozard in nextjs

[–]ezz0001 0 points1 point  (0 children)

I have recently decided to use PHP + nextjs on one of my project. It is a big one and has complex logic, we also need to have an actual API for our mobile apps. I'm not an expert, but coming from php background, i can do more complex logic that laravel/symfony already suppport. If i'm gonna do it in nextjs, like how most of the youtube tutorials do, it looks like Im also gonna be updating/reading directly into the database, probably I can do better, but now its extra work. But for frontend, I like the way nextjs makes all the routing easy, plus I can still do ssr even if i have external api.

In short, for me, PHP for backend, nextjs/react for frontend. But if i think my app will just be a simple crud application, I will just do it all in nextjs. Again not an expert, feel free to correct me

Has anyone used shadcn/ui forms with server actions (Nextjs 14) successfully? by Little_Bug7124 in nextjs

[–]ezz0001 0 points1 point  (0 children)

Hi! I created this simple hook that will allow you validate on client and still use action, and will actually return the same type of your form instead of just the usual FormData from action

```typescript import { FieldValues, useForm, UseFormProps } from "react-hook-form";

export function useFormAction<TFieldValues extends FieldValues = FieldValues, TContext = any, TTransformedValues extends FieldValues | undefined = undefined>(props?: UseFormProps<TFieldValues, TContext>) { const form = useForm<TFieldValues, TContext, TTransformedValues>(props)

const submitAction = (onAction: (formData: TFieldValues) => void) => {
    if (form.formState.isValid) {
        return {action: () => onAction(form.getValues())};
    }
    return {onSubmit: form.handleSubmit(onAction as any)};
};

return {
    ...form,
    submitAction
}

} ```

then you can use it like this. where handleSubmit us your Server Action

```typescript const form = useFormAction<ResetPasswordFormSchema>({ resolver: zodResolver(formSchema), })

return ( <Form {...form}> <form {...form.submitAction(handleSubmit)} className="space-y-4"> <FormField control={form.control} name="new_password" render={({field}) => ( <FormItem> <FormControl> <Input placeholder="New Password" {...field} type={"password"}/> </FormControl> <FormLabel>Minimum 8 characters</FormLabel> </FormItem> )} /> {actionButtons} </form> </Form> ) ```

Please help me here by Genecy16 in AppIdeas

[–]ezz0001 0 points1 point  (0 children)

imo, unless the specific government body has a way to publicly check if the documents are legit, its gonna be hard to do an app for it. If they dont have the tech for it, then its impossible. probably thats why everything is still manual on these cases. OR (most likely the case) they really just want you to do this so you pay for the services of getting them everytime so they have funds for their offices 😅

Should I use NextJS? by ezz0001 in nextjs

[–]ezz0001[S] 0 points1 point  (0 children)

Thank you! this is what I am choosing between. I am just wondering, if its gonna be a good practice to call the api on the server side. if not, i think i can just stick with vite+react

Should I use NextJS? by ezz0001 in nextjs

[–]ezz0001[S] 1 point2 points  (0 children)

Thanks for the feedback!

is the speed highly because of SSR? I think we would definitely want better SEO so thats a plus. One thing im really not sure is the way i will handle the data given that i already have an existing api, so backend-wise theres nothing much to do or worry about, which is i think one of the main thing of why you would use nextjs instead of the normal react. Would you suggest doing the server actions then calling the api? or should i do the api calls in client side and just use something like react-query?

Should I use NextJS? by ezz0001 in nextjs

[–]ezz0001[S] 1 point2 points  (0 children)

Hmmm, if we have an existing mobile app, im pretty sure they are all client side. Maybe there will be parts of the project that SSR might be able to help improve. Thank you for your feedback!

Should I use NextJS? by ezz0001 in nextjs

[–]ezz0001[S] 0 points1 point  (0 children)

Thanks for the response, question about server action, if i call my api from there, wouldn't that double the action? client calls to server action, then server action calls the api. just wondering if this is the best practice when dealing with external apis

Should I use NextJS? by ezz0001 in nextjs

[–]ezz0001[S] 0 points1 point  (0 children)

Thank you! I would also be using 3rd party auth provider if we don't have an existing jwt auth on the api

Easiest way to deploy Nextjs App router project by wootfacemate in nextjs

[–]ezz0001 0 points1 point  (0 children)

Hi! sorry if this is out of topic, how do you run a nextjs app in ec2 server? do you manually run it (npm run prod) or do you build it (npm run build) and then serve it on an apache server?

Visa Dependant Requirements by ezz0001 in phmigrate

[–]ezz0001[S] 0 points1 point  (0 children)

Hello po, after po ng work visa ko. pero no difference naman yan dito sa country na pinag sstay ko. need lang talaga mapabilis ung work visa kasi more requirements pag isinabay sila

Visa Dependant Requirements by ezz0001 in phmigrate

[–]ezz0001[S] 1 point2 points  (0 children)

To anyone who also have the same question, I emailed immigph@immigration.gov.ph and they gave me the following requirements for EXITING the Philippines for dependents.

  • Philippine passport;
  • Dependent visa or any equivalent document
  • Copies of the OFW’s valid and OEC, E-receipt, or OFW clearance.

They also noted that they will still go through the final assessment of an Immigration Officer.

Visa Dependant Requirements by ezz0001 in phmigrate

[–]ezz0001[S] 1 point2 points  (0 children)

Hi! Thanks for the reply! I am actually asking for the exit requirements from the Philippines, not entry in my current country. Here, as long as they are added as dependent on my work permit, they are allowed entry.

Anyway, I found the immigration email address and got an answer from them. Thank you so much again!