1.7.3 • Published 23 days ago
remix-routes v1.7.3
remix-routes
remix-routes
automatically generates typesafe helper functions for manipulating internal links in your Remix apps.
Installation
- Using pnpm:
$ pnpm add remix-routes
- Using yarn:
$ yarn add remix-routes
- Using npm:
$ npm add remix-routes
Setup
package.json
{
"scripts": {
"build": "remix-routes && remix build",
"dev": "concurrently \"remix-routes -w\" \"remix dev\""
}
}
Usage
import type { ActionFunction } from 'remix';
import { redirect } from 'remix';
import { $path } from 'remix-routes'; // <-- Import magic $path helper from remix-routes.
export const action: ActionFunction = async ({ request }) => {
let formData = await request.formData();
const post = await createPost(formData);
return redirect($path('/posts/:id', { id: post.id })); // <-- It's type safe.
};
Appending query string:
import { $path } from 'remix-routes';
$path('/posts/:id', { id: 6 }, { version: 18 }); // => /posts/6?version=18
$path('/posts', { limit: 10 }); // => /posts?limit=10
// You can pass any URLSearchParams init as param
$path('/posts/delete', [['id', 1], ['id', 2]]); // => /posts/delete?id=1&id=2
Checking params:
import type { ActionFunction } from 'remix';
import { $params } from 'remix-routes'; // <-- Import $params helper.
export const action: ActionFunction = async ({ params }) => {
const { id } = $params("/posts/:id/update", params) // <-- It's type safe, try renaming `id` param.
// ...
}
API
$path(path: string, params: { [key: string]: string | number }, query?: { [key: string]: string | number })
$path(path: string, query?: { [key: string]: string | number })
$params(path: string, params: { readonly [key: string]: string | undefined })
Command Line Options
-w
: Watch for changes and automatically rebuild.
License
1.7.3
23 days ago
1.7.2
3 months ago
1.7.1
3 months ago
1.6.2
3 months ago
1.7.0
3 months ago
1.6.1
4 months ago
1.6.0
4 months ago
1.5.1
5 months ago
1.4.6
7 months ago
1.5.0
7 months ago
1.4.7
7 months ago
1.4.5
8 months ago
1.4.4
11 months ago
1.4.3
12 months ago
1.4.2
12 months ago
1.4.1
1 year ago
1.4.0
1 year ago
1.2.0
1 year ago
1.1.0
1 year ago
1.0.0
2 years ago
0.6.0-alpha.1
2 years ago
1.3.1
1 year ago
1.3.0
1 year ago
1.0.0-alpha.3
2 years ago
1.0.0-alpha.2
2 years ago
1.0.0-alpha.1
2 years ago
0.5.0-alpha.1
2 years ago
0.5.1
2 years ago
0.5.0
2 years ago
0.4.0-alpha.1
2 years ago
0.3.0
2 years ago
0.2.0
2 years ago
0.4.1
2 years ago
0.4.0
2 years ago
0.4.2
2 years ago
0.1.2
2 years ago
0.1.1
2 years ago
0.1.0
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago
0.0.1-alpha.9
2 years ago
0.0.1-alpha.8
2 years ago
0.0.1-alpha.7
2 years ago
0.0.1-alpha.6
2 years ago
0.0.1-alpha.5
2 years ago
0.0.1-alpha.4
2 years ago
0.0.1-alpha.3
2 years ago
0.0.1-alpha.2
2 years ago
0.0.1-alpha.1
2 years ago
0.0.1-alpha.0
2 years ago