A Web App Framework
This is documentation, for me essentially, on how to deploy a web application. It's opinionated and will change over time. Here are the buzz words:
- Next.js
- Typescript
- Progressive Web App (PWA)
- Go
- Google Cloud Run (Serverless)
- Firebase
#
NextJS Guide#
Setup Next.jsNextjs make react simple and configurable to set up. Docs are here.
#
Setup TypescriptDocs are here
You will want to install the types as dev dependencies:
npm install --save-dev typescript @types/react
.
tsconfig.json
:
#
Setup PWAProgressive Web Apps. Docs are here.
The important part is the local /api
redirect for developement.
This redirects all /api
calls to your local backend service.
#
Setup TailwindcssDocs are here.
You need to create the tailwind.config.js
and postcss.config.js
files.
I recommend to keep the global styles.css
so you can still bundle classes together.
#
Setup DarkmodeSupport for dark mode is nice.
next-themes
provides this out of the box.
Ensure your tailwind.config.js
adds support via the darkmode class:
Add color-scheme
support to your styles.css
. More info on web.dev
#
FirebaseFirebase is a useful application framework. It has good support for mobile apps to. The web sdks are nice. The main benefit I see is for authentication.
#
APII'm a big fan of protobuffers and gRPC. It's well defined and simple with a lot of best practises built in. However it's typically not been usefull for any front end work as the internal protocol of gRPC is based on binary HTTP2 with trailing headers that aren't supported in the browser. Although now there are a couple options:
- gRPC Web
- REST Transcoding
My preferred is transcoding. It gives a nice RESTful style api that doesn't feel like a generated API.
#
LarkingLarking is my transcoding project.
It uses the new protobuf apiv2 to
parse the http options, generating the REST bindings.
The best part is that it does this on the fly.
No extra protoc
options or dealing with the generated runtime code.
It can do this via server side reflection too, making it a proxy that adapts to the server changes without having to reboot.
Although the most useful case I've had is for the server to run both the gRPC service and the http REST service.
Below is my function that serves on the listener until failure:
#
ProtocProtoc build command:
To keep the frontend in-sync with the backend I use a typescript integration from ts_proto
.
Docs here.
One unsolved problem is the generation of calling code.
I don't have autogenerated handlers for calling the API yet.
#
LayoutI like flat layouts. Specially for small projects. I think it greatly simplifies it. Everything is visible, nothing is hidden away in the depths. It's realy not a big deal how things are laid out but it helps to have a structure. Web app projects are tightly integrated between the frontend and backend. The API is used to "decouple" the two, but if you want to change the API you need to ensure both still work. I've found it nice to have the backend/frontend code living close together.
#
DeploymentGoogles ko
is great!
One command deployment to gcloud run:
I've used bazel before and wanted to reuse it in projects.
However, most of the time I find it gets in the way more than anything.
It doesn't play nicely with the localy tools so editors and bazel constantly rebuild your code.
Protoc support works, but I've had it break constantly on multiple upgrades.
Bazel server isn't light either.
I'm working with an older mac that needs all the ram it can get.
So for now I've been happy with ko
.
For projects that require cgo
I use zig
.
Docs here.
I've then been using bazel for only building the container iamges and deploying them.
This is sub optimal.
So I have a new project laze
!
laze
is a local tool friendly, build graph exectutor.
It tries to be a simple version of bazel.
Docs for it here.
I'll do a writeup once I get some more core features added.
For the frontend:
Firebase code need to know about the proxy.
firebase.json