Bot releases are hidden (Show)
Published by tatethurston 24 days ago
Adds support for Next.js's app
directory. Link
accepts either static routes (no url parameters) or a RouteLiteral
string, which can be generated by the route
helper from this library:
import { route } from "nextjs-routes";
<Link
href={route({
pathname: "/foos/[foo]",
query: { foo: "bar" },
})}
>
Baz
</Link>;
Add RouteLiteral
type. This type represents a string that confirmed to be a validated application route and can be passed to Link
or useRouter
. This is a TypeScript branded type.
import { RouteLiteral } from "nextjs-routes";
Refine types for usePathname
and useParams
from "next/navigation"
to use nextjs-routes
generated types.
Fix generated routes when using parallel-routes and intercepting-routes.
Fix ref
type for Link
. Previously ref
was missing, now it's correctly typed.
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v2.2.2-rc.3...v2.2.2-rc.4
Published by tatethurston 29 days ago
Adds support for Next.js's app
directory. Link
accepts either static routes (no url parameters) or a RouteLiteral
string, which can be generated by the route
helper from this library:
import { route } from "nextjs-routes";
<Link
href={route({
pathname: "/foos/[foo]",
query: { foo: "bar" },
})}
>
Baz
</Link>;
Add RouteLiteral
type. This type represents a string that confirmed to be a validated application route and can be passed to Link
or useRouter
. This is a TypeScript branded type.
import { RouteLiteral } from "nextjs-routes";
Refine types for usePathname
and useParams
from "next/navigation"
to use nextjs-routes
generated types.
Fix generated routes when using parallel-routes and intercepting-routes.
Published by tatethurston 29 days ago
Adds support for Next.js's app
directory. Link
accepts either static routes (no url parameters) or a RouteLiteral
string, which can be generated by the route
helper from this library:
import { route } from "nextjs-routes";
<Link
href={route({
pathname: "/foos/[foo]",
query: { foo: "bar" },
})}
>
Baz
</Link>;
Add RouteLiteral
type. This type represents a string that confirmed to be a validated application route and can be passed to Link
or useRouter
. This is a TypeScript branded type.
import { RouteLiteral } from "nextjs-routes";
Refine types for usePathname
and useParams
from "next/navigation"
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v2.2.2-rc.1...v2.2.2-rc.2
Published by tatethurston about 1 month ago
Adds support for Next.js's app
directory. Link
accepts either static routes (no url parameters) or a RouteLiteral
string, which can be generated by the route
helper from this library:
import { route } from "nextjs-routes";
<Link
href={route({
pathname: "/foos/[foo]",
query: { foo: "bar" },
})}
>
Baz
</Link>;
Add RouteLiteral
type. This type represents a string that confirmed to be a validated application route and can be passed to Link
or useRouter
. This is a TypeScript branded type.
import { RouteLiteral } from "nextjs-routes";
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v2.2.0...v2.2.1
Published by tatethurston 5 months ago
trailingSlash
option to route
. See #168
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v2.1.0...v2.2.0
Published by tatethurston 12 months ago
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v2.0.1...v2.1.0
Published by tatethurston over 1 year ago
Fix GetServerSidePropsContext
and GetServerSidePropsResult
types. Thanks @po4tion!
Change generated file location from nextjs-routes.d.ts
to @types/nextjs-routes.d.ts
. Thanks @po4tion!
To preserve the old location, make the following change to your next.config.js
:
const nextRoutes = require("nextjs-routes/config");
const withRoutes = nextRoutes({
+ outDir: "",
});
Otherwise, delete your old nextjs-routes.d.ts
once @types/nextjs-routes.d.ts
is generated.
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v2.0.0...v2.0.1
Published by tatethurston over 1 year ago
next build
/ next dev
by using npx nextjs-routes
.router.query
types must now be narrowed using router.isReady
. This ensures types are correct for pages that use Automatic Static Optimization.Next's documentation notes the following:
During prerendering, the router's query object will be empty since we do not have query information to provide during this phase. After hydration, Next.js will trigger an update to your application to provide the route parameters in the query object.
See #117 for more context and discussion.
import { useRouter } from "next/router";
const router = useRouter<"/foos/[foo]">();
// query is now typed as `{ foo?: string | undefined }`. Previously this was `{ foo: string }` which was not safe for static optimized pages
router.query;
Updating useRouter
call sites to check isReady
will narrow the query type:
import { useRouter } from "next/router";
const router = useRouter<"/foos/[foo]">();
// query is now typed as `{ foo?: string | undefined }`. Previously this was `{ foo: string }` which was not safe for static optimized pages
router.query;
+ if (router.isReady) {
+ // query is typed as `{ foo: string }`
+ router.query;
+ }
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.9...v2.0.0
Published by tatethurston over 1 year ago
Link
and router
methods to only update the route hash
. Thanks @sitch!route
runtime so jest tests don't require transpilation for users. Thanks @panudetjt!GetServerSideProps
and GetServerSidePropsContext
types. Thanks @slhck!Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.8...v1.0.9
Published by tatethurston over 1 year ago
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.7...v1.0.8
Published by tatethurston almost 2 years ago
TypeError[ERR_IMPORT_ASSERTION_TYPE_MISSING]
. See #115 for more context.Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.6...v1.0.7
Published by tatethurston almost 2 years ago
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.5...v1.0.6
Published by tatethurston almost 2 years ago
nextjs-routes
is now included in the generated nextjs-routes.d.ts
file.Link
to use TypeScript unions instead of function overloading. Function overloading resulted in errors that were difficult for users to understand, and created issues for some use cases.Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.4...v1.0.5
Published by tatethurston almost 2 years ago
LinkProps
now accept path strings for static routes:
import { LinkProps } from "next/link";
// previously this would error
const props: LinkProps = { href: "/foo" };
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.3...v1.0.4
Published by tatethurston almost 2 years ago
The Route
type now includes hash
. This enables the following:
// this will link to /foo#bar
<Link href={{ pathname: "/foo", hash: "bar" }}>Foo</Link>
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.2...v1.0.3
Published by tatethurston almost 2 years ago
Link
now accepts anchor props:
<Link href="/dashboard" className="border-indigo-500">
Dashboard
</Link>
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.1...v1.0.2
Published by tatethurston almost 2 years ago
Update NextRouter
type to keep query
and pathname
bound in a union. This allows you to use router
from useRouter
as an argument to router.push
or router.replace
:
const router = useRouter();
// reload the current page, preserving search parameters
router.push(router, undefined, { locale: "fr" });
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v1.0.0...v1.0.1
Published by tatethurston almost 2 years ago
This library will now follow semantic versioning.
The previously deprecated direct invocation of nextjs-routes via npx nextjs-routes
has been removed in favor of automatic regeneration via withRoutes. See #63 for the motivation behind this change or to voice any concerns.
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v0.1.7...v1.0.0
Published by tatethurston almost 2 years ago
Support Next 13 app (beta) directory
Add dir
option to support non standard NextJS project structures such as Nx:
// next.config.js
const withRoutes = require("nextjs-routes/config")({ dir: __dirname });
Thanks @alexgorbatchev for the contribution!
Full Changelog: https://github.com/tatethurston/nextjs-routes/compare/v0.1.6...v0.1.7