Learn more about Remix Stacks.
npm init remix -- --template markmals/lo-fi-stack
Not a fan of bits of the stack? Fork it, change it, and use npm init remix -- --template your/repo
! Make it your own.
From your terminal:
npm run dev
This starts your app in development mode, rebuilding assets on file changes.
.env
-fileapp/lib/firebase/auth.server.ts
signIn
returns a Firebase session-cookie-string, when sign-in is successfull. Then Remix cookieSessionStorage
is used to set, read and destroy it.
signUp
creates a user and calls sign-in to receive the session cookie.
requireAuth
uses firebase-admin
to verify the session cookie. When this check fails, it throws a redirect
to the login page. Use this method to protect loaders and actions. The returned UserRecord
can be handy to request or manipulate data from the Firestore for this user.
app/lib/firebase/db.server.ts
The default setup exports Holocron databases connected to Firestore collections.
Requests to the Firestore are made using the firebase-admin
-SDK. You need to check validity of your requests manually, since firestore.rules
don't apply to admin requests.
For lower level tests of utilities and individual components, we use vitest
. We have DOM-specific assertion helpers via @testing-library/jest-dom
.
This project uses TypeScript. It's recommended to get TypeScript set up for your editor to get a really great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run npm run typecheck
.
This project uses ESLint for linting. That is configured in .eslintrc.js
.
We use Prettier for auto-formatting in this project. It's recommended to install an editor plugin (like the VSCode Prettier plugin) to get auto-formatting on save. There's also a npm run format
script you can run to format all files in the project.
Sign up and log in to Fly
flyctl auth signup
flyctl launch
Once you've followed the setup instructions, all you need to do is run this:
npm run deploy
You can run flyctl info
to get the url and ip address of your server.
Check out the fly docs for more information.
This repo has been modified to add static site generation capabilities.
Ensure you have wget
installed:
which wget
If not, install it:
brew install wget
To build your site statically, first do a normal build and boot the production server as shown above.
Then, in a separate terminal tab do:
npm run build-static
This will generate a static
directory with the HTML files and assets you need to serve a fully hydrated Remix site. It uses wget
to pull HTML, CSS, and JS from the server you have running in the other tab. It pulls all the URLs listed in static-urls.txt
. Once it completes, you can shut down the local server.
To test out your static build, run:
npm run serve-static
To deploy, just copy the static
dir to your static hosting provider.
IMPORTANT
This isn't typically how Remix works (we usually have a server) so you'll want to note a few things about this setup:
loader
still works (see app/routes/one.tsx
and app/routes/two.tsx
) so you can still grab data from the filesystem or from your database and put it into your markup via useLoaderData
<Scripts>
element in app/root.tsx
) all navigation on the site should be done with a full document reload (using <Link reloadDocument>
). This is because no server is running to be able to dynamically serve the data we need for the new route when we do a client-side transition to it. However, the data is already encoded in the HTML in the static
output directory we generated in the build-static
command.action
) will not work.