0.8.9 • Published 7 months ago
next-ssr-middleware v0.8.9
Next SSR middleware
Koa-like middlewares for Next.js Server Side Rendering
Versions
SemVer | status | MobX | MobX i18n |
---|---|---|---|
>=0.7 | ✅developing | >=6.11 | >=0.5 |
<0.7 | ❌deprecated | >=4 <6.11 | <0.5 |
Middlewares
- Router
- Error logger
- JWT verifier
- Props cache
- i18n loader
- OAuth 2 signer (with common providers)
- GitHub
Usage
pages/user/[id].tsx
import {
JWTProps,
RouterProps,
jwtVerifier,
cache,
errorLogger,
router,
translator
} from 'next-ssr-middleware';
import i18n from '../../model/Translation';
import { User, UserModel } from '../../model/User';
type UserDetailPageProps = User & JWTProps & RouterProps;
export const getServerSideProps = compose<{ id: string }, UserDetailPageProps>(
jwtVerifier(), // set `JWT_SECRET` in `.env.local` first
cache(),
errorLogger,
router,
translator(i18n),
async ({ params }) => {
const props = await new UserModel().getOne(params!.id);
return { notFound: !props, props };
}
);
export default function UserDetailPage({
jwtPayload,
route,
name,
summary
}: UserDetailPageProps) {
return (
<>
<h1>
{name} - {route.params!.id}
</h1>
<p>{summary}</p>
</>
);
}
Cases
0.8.9
7 months ago
0.8.8
8 months ago
0.8.5
10 months ago
0.8.4
10 months ago
0.8.7
10 months ago
0.8.6
10 months ago
0.8.1
1 year ago
0.8.0
1 year ago
0.8.3
10 months ago
0.8.2
11 months ago
0.7.0
1 year ago
0.6.2
1 year ago
0.6.1
2 years ago
0.5.2
2 years ago
0.6.0
2 years ago
0.5.3-rc.0
2 years ago
0.5.1
2 years ago
0.5.0
2 years ago