#Best way to start a new project

4 messages · Page 1 of 1 (latest)

sonic pelican
#

@bronze imp what is the best and easiest way to get a new project started in Convex using ConvexAuth with ResendOTP authentication? Ideally nextjs but open to suggestion.

bronze impBOT
#

Hi @sonic pelican. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

The best and easiest way to start a new project in Convex using ConvexAuth with ResendOTP authentication, especially with Next.js, is to use the npm create convex command. Here's a step-by-step guide based on the knowledge sources:

  1. Run the following command to create a new Convex project:
npm create convex@latest
  1. When prompted, choose "Next.js" as your client and "Convex Auth" for user authentication Start building faster with npm create convex (https://stack.convex.dev/npm-create-convex#start-building-faster-with-npm-create-convex).

  2. Follow the setup instructions provided after the project is created. This will typically include:

    • Changing to the project directory
    • Running npm run dev to start the development server
  3. For ResendOTP authentication, you'll need to configure it in your project. Here's how:

    • Install the necessary dependencies:

      npm install [email protected] oslo
      
    • Create a custom provider config for sending an OTP. Add a file ResendOTP.ts in your convex/ folder with the configuration Auth > Config > OTPs (https://labs.convex.dev/auth/config/otps).

    • Set up your Resend API key as an environment variable:

      npx convex env set AUTH_RESEND_KEY yourresendkey
      
    • Update your convex/auth.ts file to use the ResendOTP provider.

  4. For the frontend, you can use the provided React components and hooks from Convex Auth to handle authentication in your Next.js pages.

This approach gives you a solid starting point with Next.js and Convex, including ConvexAuth setup. You can then customize the ResendOTP authentication as needed for your specific project requirements.

Remember that Convex Auth is currently in beta, so be prepared for potential changes or updates Convex Auth (https://labs.convex.dev/auth).

#

If you need more detailed guidance on setting up ResendOTP or configuring your Next.js app with Convex, you can refer to the specific documentation sections I've cited above.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: