All Projects → sergiodxa → micro-next

sergiodxa / micro-next

Licence: MIT license
Integrations between Micro and Next.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to micro-next

Unfurl
Scraper for oEmbed, Twitter Cards and Open Graph metadata - fast and Promise-based ⚡️
Stars: ✭ 193 (+865%)
Mutual labels:  micro
tcl-modules
A collection of pure Tcl, production-ready micro packages
Stars: ✭ 25 (+25%)
Mutual labels:  micro
micro-ex-router
Express like router for micro.
Stars: ✭ 20 (+0%)
Mutual labels:  micro
Reshader
A micro, highly-customisable JavaScript library to get shades of colors
Stars: ✭ 214 (+970%)
Mutual labels:  micro
s3-example
Simple example using micro for uploading stuff to AWS S3.
Stars: ✭ 45 (+125%)
Mutual labels:  micro
Mvvmicro
Minimalist MVVM framework for .NET.
Stars: ✭ 22 (+10%)
Mutual labels:  micro
Xconf
分布式配置中心
Stars: ✭ 185 (+825%)
Mutual labels:  micro
miki
Wiki system in PHP+NoDB in just one file. 10s setup + auto-installed. Full Markdown support. Super fast and lightweight (-0.01MB gzip). Multi-User support. Minimal and beautiful.
Stars: ✭ 25 (+25%)
Mutual labels:  micro
m.test
m(icro)test is a lightweight test runner for node.js written in es6+
Stars: ✭ 17 (-15%)
Mutual labels:  micro
micro-cacheable
A micro utility for data caching
Stars: ✭ 35 (+75%)
Mutual labels:  micro
project-lighthouse
Project Lighthouse is a clean-room, open-source custom server for LittleBigPlanet.
Stars: ✭ 139 (+595%)
Mutual labels:  custom-server
micro-superstruct
A Superstruct wrapper for Micro to validate your request body and query parameters
Stars: ✭ 15 (-25%)
Mutual labels:  micro
micro-query
Simple query string parser for Vercel's Micro
Stars: ✭ 23 (+15%)
Mutual labels:  micro
Qian
A minimalist file-explorer using Electron via Elm !
Stars: ✭ 198 (+890%)
Mutual labels:  micro
micro-starter
Micro 微服务实践
Stars: ✭ 391 (+1855%)
Mutual labels:  micro
Go Os
Stars: ✭ 185 (+825%)
Mutual labels:  micro
micro
abp+micro+typescript+vue+element
Stars: ✭ 92 (+360%)
Mutual labels:  micro
micro-visualize
Visualizes requests and responses for services written with micro
Stars: ✭ 55 (+175%)
Mutual labels:  micro
micro-chain
🤝 Helps to build chains from your micro services.
Stars: ✭ 24 (+20%)
Mutual labels:  micro
dockerpkg-example
Example app running in small docker container using dockerpkg
Stars: ✭ 54 (+170%)
Mutual labels:  micro

micro-next

Integrations between Micro and Next.js.

Usage

Install it from npm:

yarn add micro-next

Create a routes.json file with a list of pages, similar to this one:

[
  {
    "method": "GET",
    "path": "/blog",
    "page": "/blog/posts",
    "name": "blog-posts"
  },
  {
    "method": "GET",
    "path": "/blog/:post",
    "page": "/blog/post",
    "name": "blog-post"
  }
]

Create a server.js file with the following code:

const routes = require("./routes.json");
const microNext = require("micro-next");

module.exports = microNext({
  routes,
  next: {
    dev: process.env.NODE_ENV !== "production"
  }
});

And if you want to easily integrate this client side create a lib/get-page.js file with the following content:

import get from "micro-next/get";
import routes from "../routes.json";

export default get(routes);

Now you can use it with next/link:

import Link from "next/link";
import getPage from "lib/get-page.js";

export default () => (
  <Link {...getPage("blog-post", { post: 1 })}>
    <a>Go to blog post 1</a>
  </Link>
);

API

micro-next

A function used to initialize a Next.js custom server with Micro.

It returns a Micro-ready request handler which run app.prepare and setup the routes.

micro-next/get

A function used to get the routes by the name already formated to be used with next/link.

  • routes (array) The list of custom routes

This function returns a new function you can export and use to get the href and as to pass to next/link.

  • pageName (string) The name of route as defined in your list of routes
  • params (object) The parameters to use in the URL
  • query (object) The query to add in the URL (default {})

The function returns an object with the following data:

  • href (string) The real path of the URL
  • as (as) The URL to show in the browser
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].