Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiodxa committed May 13, 2024
1 parent 5e946b9 commit 03f1574
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
52 changes: 50 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
# package
# remix-define-routes

A template to create new packages.
A DSL to define Remix routes with code.

## Setup

```bash
npm add remix-define-routes
```

Create a file called `routes.ts` in your Remix project.

```ts
import { defineRoutes } from "remix-define-routes";

let authRoutes = defineRoutes(({ layout }) => {
layout("auth", { base: "routes/auth" }, ({ route }) => {
route("index", "routes/auth._index");
route("register");
route("login");
});
});

export default defineRoutes(({ route, extend }) => {
extend(authRoutes);

route("api/healthcheck");
route("index", "routes/_index");
route("admin/:resource");
});
```

Then in your `vite.config.ts` import and use it to configure your Remix plugin.

```ts
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";

import routes from "./config/routes";

export default defineConfig({
plugins: [
remix({
ignoredRouteFiles: ["**/*"],
routes: () => routes,
}),
],
});
```

And now you can use route routes file to define your application routes.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "package-name",
"name": "remix-define-routes",
"version": "0.0.0",
"description": "A description of the package",
"description": "A DSL to define Remix routes with code",
"license": "MIT",
"funding": ["https://github.com/sponsors/sergiodxa"],
"author": {
Expand Down

0 comments on commit 03f1574

Please sign in to comment.