Skip to main content
In this guide, you will:
  1. Create a new project using create-lofi-app
  2. Customize the homepage and schema
  3. Connect to a Basic project
  4. Add sign in and sign out functionality

installation

1

Create a new project

Terminal
When prompted in the CLI, enter y for installing the vite package. Then give your project a name. And finally choose the Basic + Tailwind variant.

running the app

1

install npm packages

cd project-name into your project, run npm i, and start your server with npm run dev:
Terminal
You’ll now be able to navigate to http://localhost:5173 and see the app running as below: create-lofi-app template

customizing the app

1

change the homepage

Let’s delete the existing code and simplify it by printing “my lofi app”.
App.tsx
2

update the schema

set up the schema based on your project needs and as per the schema docs.
basic.config.ts
You’re ready to test and develop your app locally!

testing sync and Auth

You can continue to test the app locally without the following steps, but if you wish to test sync and Auth, you would need to create a Basic project and connect it to the app.
1

create and connect to a Basic project

You can use the Basic CLI to create a new project (the basic init command will automatically update the basic.config.ts file with the project_id). You will need to basic push to update the version number in the basic.config.ts file.…or use the Basic dashboard to create and connect to a new Basic project (make sure to update the basic.config.ts file with the project_id). You will need to manually update the version number in the basic.config.ts file to match the version number in your Basic admin project dashboard.
basic.config.ts
2

Add a login button to App.tsx

Now navigate to src/App.tsx and import signin, isSignedIn, and user.
App.tsx
Let’s test it out! Clicking on the button should now redirect you to the Basic.id page where your users can login or create an account. Once they’re done, they’ll be redirected back to your app and see their email displayed.
3

Add a logout button

Use the isSignedIn hook to check if the user is logged in, and the signout function to sign out the user:
App.tsx
That’s it! You’ve successfully added Basic Auth to your React app 🎉

Using the database

You can use the React SDK documentation to read and write to the user’s database. Checkout the React SDK docs to get started.