A starter kit using Remix with HTTP-only cookie authentication (preauth/postauth), flat routes, and Axios as the HTTP client. Great for building secure web apps with a complete login/logout flow.
- Flat Routes — clean and simple Remix route structure.
- HTTP-only JWT Cookie Auth — secure against XSS attacks.
- Axios instance ready to use (
~/lib/Axios
) withwithCredentials: true
to ensure cookies are always sent. - Preauth & Postauth Layouting:
__preauth+/login.tsx
— for public login pages.__postauth+/dashboard.tsx
in postauth area — for authenticated users only.
- Routing with Access Protection — layout loader checks token from cookie; redirects to
/login
if invalid.
To speed up Remix app development with:
- Secure and ready-to-use authentication (login using HTTP-only cookie).
- Simple flat routing.
- Automatic layout separation for public and authenticated pages.
- Preconfigured Axios for stable communication with a separate backend.
npx create-remix-boilerplate ./my-app
Or
git clone https://github.com/Alpharii/remix-boilerplate.git
cd remix-boilerplate
npm install
Copy .env.example
to .env
and fill in the variables:
VITE_API_URL=https://api.example.com
NODE_ENV=development
-
Development Mode:
npm run dev
-
Production Build & Preview:
npm run build npm run start
app/
├─ routes/
│ ├─ __preauth+/
│ │ └─ login.tsx # Public login page
│ ├─ __postauth+/ # Authenticated/protected routes
│ │ └─ dashboard.tsx # Example authenticated page
│ ├─ __preauth.tsx # Main layout after login
│ ├─ __postauth.tsx # Main layout before login
│ └─ index.tsx # Redirect to login or dashboard
lib/
└─ Axios.ts # Axios instance with credentials
- User logs in via the
POST /login
form. The server sets a HTTP-only cookietoken
. - Axios is used both in client and Remix loaders, always sending the cookie.
- Postauth layout (
__postauth.tsx
) runs a loader:- Parses the
token
cookie. - Calls an api. If it fails, redirects to
/login
.
- Parses the
- If successful, renders the layout +
Outlet()
for page content.
- Add sidebar or toolbar in
__postauth.tsx
. - Add new protected pages under
__postauth+
. - Change backend API by editing
VITE_API_URL
and login/me response format. - Increase security by enabling SameSite + Secure on cookies.
- Make sure your backend allows cross-site cookies (
CORS
,SameSite=None
,Secure
). - Always use
withCredentials: true
in Axios to send cookies. - Never store tokens in localStorage; always use HTTP-only cookies.
- Fork and create a new branch.
- Add your features or bug fixes.
- Open a Pull Request.
MIT License. See LICENSE for details.