Skip to content

RemixJS

Posted on:September 23, 2022 at 03:22 PM

To run development server: remix dev To build app for production: remix build

Remix folder structure

when you build(remix build) remix application, following folders are created.

Nested routes:

Note: Routes can also be created programatically via the remix.config.js file.

Each file we put in the app/routes directory is called a “Route Module” and by following the route filename convention, we can create the routing URL structure we’re looking for. Remix uses React Router under the hood to handle this routing.

index route (/) is handled by file/module at app/routes/index.tsx.

Nested routes and styling

Remix brings the power of its Nested Routing support to CSS and allows you to associate links to routes. When the route is active, the link is on the page and the CSS applies. When the route is not active (the user navigates away), the link tag is removed and the CSS no longer applies.

.server part of the filename informs Remix that this code should never end up in the browser.

TW CSS support

Link tag with to attribute set as ’.’ refreshes the page(sends fetch, Get, post?) and updates the page data.

Mutations/Forms

HTML form attributes

When the user submits a form, Remix will:

HTML forms support two HTTP verbs: GET: Remix will figure out what parts of the page are changing and only fetch the data for the changing layouts, and use the cached data for the layouts that don’t change POST: Remix will reload all data to ensure it captures the update from the server.

HTML get: It is mostly used in search pages. Data is sent in query string (search params), it is similar to navigation via the link <a> tag except that the URL is provided by the user.

HTML form vs Remix Form:

SSR vs SSG