This is a React template that uses the following technologies:
- React
- Typescript
- Vite, for bundler
- SWR, for data fetching
- Convex, for BaaS
- Clerk, for AaaS
- React-Router-Dom
- Tailwind
- Run
npm i
- Optional:
cp .env.example .env.local
. Alternatively convex will create it for you, skip to the next step. - Run
npx convex dev
, to hook into convex dev environment. Select the add new project option. - Add your publishable key to .env.local. You get this when you add a new app to your dashboard at clerk.com.
Pages that are public and should not be required to log in via Clerk should be added to the router in routes/index as normal.
Pages that need to require a user to be logged in should do the following.
- Add a new page to the router in routes/index.
- Use the component as the parent layout to enforce the user to be logged in. See the 'profile' path as an example.
Note: This only requires a user to be logged in via Clerk, however, further limitations should be easy to add.
- Add a new JWT template to your app in Clerk. The template should be Convex.
- Copy the issuer box from your JWT template in Clerk and add it to convex/auth.config.js as the domain.
- Call the hook
useStoreUserEffect
within your routes/Layout file.
SWR has been added for external data fetching, its configuration can be found in config/swr
. By default this template sets refetch to 3000ms.