Now that you have created your Lx2 project, you can start building your application. Here are some resources to help you get started:
Database
MySQL, PostgreSQL, or SQLite
If you have chosen to use a database with your project, you need to populate the
DATABASE_URL
environment variable in your .env
file.
# The connection string should look something like this:
DATABASE_URL="mysql://user:password@localhost:3306/database"
You can choose to run your database locally, using a service like Docker, or use a cloud service like Neon. Alternatively, you can use SQLite for local development. SQLite is the default database for Lx2 projects, and no additional setup is required to get started.
Prisma and Drizzle cannot be used at the same time, so you will need to choose one or the other.
Prisma
We recommend using Prisma to interact with your database. Prisma is a modern database toolkit that makes it easy to interact with your database using TypeScript. If you chose to include Prisma ensure you run the following commands.
pnpm db:push && pnpm postinstall
The above command will:
- Push your prisma schema to your database, creating the necessary tables and relationships.
- Generate the Prisma client, which is used to interact with your database in your application code, in a type-safe manner.
The postinstall
script in your package.json runs prisma generate
, and will
automatically run after installing dependencies.
Drizzle
Drizzle is another ORM that you can use with your Lx2 project. It is designed to
work seamlessly with modern JavaScript and TypeScript applications. If you chose
to include Drizzle, make sure to check the .env
file and fill in the
DATABASE_URL
variable. To push your schema to your database, run the following
command:
pnpm db:push
# or
pnpm db:generate && pnpm db:migrate
Authentication
Auth.js and Better Auth
For authentication, you can choose between the two below libraries. Both libraries are great options, but they have different features and capabilities.
Auth.js is a great option if you want a simple and easy-to-use authentication library. It has a lot of built-in providers and is easy to set up. Better Auth is a more customizable option that allows you to extend your authentication flow with many different plugins.
A list of all the providers for both libraries can be found below:
Better Auth does not have a dedicated page for providers, but you can find
them in the docs under the Authentication
section in the sidebar.
Setup
By default, create-lx2-app will set up Discord as the authentication provider, so:
- Of course, you need a Discord account, so register one if you don't already have one.
- Navigate to the Discord Developer Portal and create a new application, by clicking on the "New Application" button.
- Give your application a name and click
Create
. - Head to the
OAuth2
section and copy theClient ID
to your.env
file. - Next click
Reset Secret
, then copy theClient Secret
to your.env
file. - Next, click
Add Redirect
and type the URL of you application followed by/api/auth/callback/discord
.- In development, this will be
http://localhost:3000/api/auth/callback/discord
. - In production, this will be
https://yourdomain.com/api/auth/callback/discord
.
- In development, this will be
- Finally, save your changes.
Now you should be able to sign in with Discord.
Extensions
We recommend using the following extensions for an optimal development experience.
Start Building
- Take a look around the project structure and familiarize yourself with the codebase.
- Read the docs to learn more details about the project and how to use it.
- Start building your application!