How do you build a fullstack app from scratch? I see this question here all the time.
The answer is something like:
- next.js
- python
- sagemaker
- tailwindcss
- C++
- typescript
- java
- sql
Makes 0 sense.
Here's a guide on building a fullstack JavaScript app in 15 mins 🧵
We're going to use Remix for this project.
Get started with:
❯ npx create-remix@latest
This will set up a directory with code and run npm install for you.
Start the site to see it:
❯ npm run dev
Idea: We're going to track our water and coffee drunk in a database.
Set up Prisma so we can talk to the db. Prisma is a database client for TypeScript and Node.
I install it, then add a new model. Now I can push my new table to SQLite. We can switch to something else later.
Before we can access our database from code, we also need to create a file that helps us make a connection to Prisma.
Add a file named app/lib/db.server.ts.
The .server.ts part of the filename is pretty cool. It ensures that Remix will never bundle it and send it to clients.
Another note here about Prisma. It comes with an inbuilt visual data browser for you to look at your database.
Try it out:
❯ npx prisma studio
I used the studio to manually add a few records of the liquids I've drunk today. 1 x ☕️, 2 x 💧
Now we are finally going to connect our app to the database! Drumroll 🥁 please.
Open up app/routes/index.tsx that the Remix create made for you and delete everything in it. Let's replace it with this instead.
Reload your site and behold, your beverage consumption ala Wordle.
We need to enter data into the database somehow, so next let's work on a form to submit what we are currently drinking.
Forms in Remix are super simple. No need to build an API or anything.
First we create a form, and then we create the form handler.
Let's try it out! And there we go. 🎇💥
Okay Twitter video upload is broken so I have to do a screenshot. I promise it works.
Twitter issue is killing me 😂 I'll convert this tutorial to a detailed post with code samples on my blog soon, along with how to deploy it to production. If that is something you're interested in, follow me and I'll post about it when it's ready.
Stay hydrated, my friends! 🌊
I haven't written the article yet but here's the code if that's helpful to someone. github.com/needcaffeine/f…
• • •
Missing some Tweet in this thread? You can try to
force a refresh
✨ I made a no-code feature flag system with Airtable and am using that to hide or display sections on a Next.js site. ✨
That's one way to help a client who can't decide when exactly something should go live on their site. 🤷🏾♂️
Here's how I did it. First I have a table that looks something like this. This is what the client sees when they edit the "Features" table (base, in Airtable lingo).
Airtable gives you an automatic API for each base. In the case of the Features base, I click into the API documentation and see that it looks like this.
This is a test base, I am not worried that you see my base ID in the screenshot.
If you are building a SaaS from scratch, have your Users belong to Teams, and attach billing information to the Team not User. While you're there, create a Membership model to be the join table between User/Team and assign a role to the User like Owner, Admin, or Readonly.
This signals that your app is business-friendly. It allows you to assign limits and features at the Team level. It allows for users to ask for their accounts to be deleted without it affecting the billing status of the entire team. It allows a team to kill a teammate's account.
"but I'm building a b2c, do I need teams?"
Personal finance tool: user wants spouse to see their budget
Notetaking tool: user wants to share notes with family
Videogame recc app: user wants girlfriend to add their games to library